Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libcdi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpim-sw
libcdi
Commits
e8620df7
Commit
e8620df7
authored
7 years ago
by
Thomas Jahns
Committed by
Sergey Kosukhin
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add caching for PIO chunk writes.
parent
0b3e4eb1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!34
Version 2.2.0
,
!13
Consolidation with CDI-PIO (develop)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/pio_client.c
+47
-10
47 additions, 10 deletions
src/pio_client.c
with
47 additions
and
10 deletions
src/pio_client.c
+
47
−
10
View file @
e8620df7
...
...
@@ -13,12 +13,15 @@
#include
"dmemory.h"
#include
"namespace.h"
#include
"taxis.h"
#include
"vlist.h"
#include
"cdipio.h"
#include
"pio.h"
#include
"pio_client.h"
#include
"pio_dist_grid.h"
#include
"pio_comm.h"
#include
"pio_id_set.h"
#include
"pio_idxlist_cache.h"
#include
"pio_interface.h"
#include
"pio_rpc.h"
#include
"pio_util.h"
...
...
@@ -155,25 +158,45 @@ cdiPioClientStreamWriteVar_(int streamID, int varID, int memtype, const void *da
" use streamWriteVarPart!"
);
}
static
struct
cdiPioIdxlistCache
*
clientIdxlistCache
;
static
size_t
neededClientIdxlistCacheSize
;
static
struct
idList
seenStreamWriteVarChunk
;
static
void
cdiPioClientStreamWriteVarChunk_
(
int
streamID
,
int
varID
,
int
memtype
,
const
int
rect
[][
2
],
const
void
*
data
,
size_t
nmiss
)
{
if
(
memtype
!=
MEMTYPE_DOUBLE
&&
memtype
!=
MEMTYPE_FLOAT
)
Error
(
"Writing of type data %d not implemented!"
,
memtype
);
int
vlistID
=
streamInqVlist
(
streamID
);
if
(
indexOfID
(
&
seenStreamWriteVarChunk
,
vlistID
)
==
SIZE_MAX
)
{
insertID
(
&
seenStreamWriteVarChunk
,
vlistID
);
int
nvars
=
vlistNvars
(
vlistID
);
neededClientIdxlistCacheSize
+=
(
size_t
)
nvars
;
clientIdxlistCache
=
cdiPioIdxlistCacheResize
(
clientIdxlistCache
,
neededClientIdxlistCacheSize
);
}
int
size
=
vlistInqVarSize
(
vlistID
,
varID
),
varShape
[
3
];
/* FIXME: ndims does not work this way, ndims == 2 means
* varShape[1] == 1 and can be left out */
unsigned
ndims
=
(
unsigned
)
cdiPioQueryVarDims
(
varShape
,
vlistID
,
varID
);
int
ndims
=
cdiPioQueryVarDims
(
varShape
,
vlistID
,
varID
);
Xt_int
varShapeXt
[
3
],
origin
[
3
]
=
{
0
,
0
,
0
};
int
chunkShape
[
3
]
=
{
1
,
1
,
1
};
/* FIXME: verify xt_int ranges are good enough */
for
(
unsigned
i
=
0
;
i
<
3
;
++
i
)
varShapeXt
[
i
]
=
varShape
[
i
];
for
(
unsigned
i
=
0
;
i
<
ndims
;
++
i
)
chunkShape
[
i
]
=
rect
[
i
][
1
]
-
rect
[
i
][
0
]
+
1
;
int
varSize
=
varShape
[
0
]
*
varShape
[
1
]
*
varShape
[
2
];
xassert
(
varSize
==
size
);
Xt_idxlist
chunkDesc
=
xt_idxsection_new
(
0
,
(
int
)
ndims
,
varShapeXt
,
chunkShape
,
origin
);
if
(
ndims
==
3
)
for
(
int
i
=
0
;
i
<
3
;
++
i
)
varShapeXt
[
i
]
=
varShape
[
i
];
else
{
varShapeXt
[
0
]
=
varShape
[
0
];
varShapeXt
[
1
]
=
varShape
[
2
];
}
for
(
int
i
=
0
;
i
<
ndims
;
++
i
)
chunkShape
[
i
]
=
rect
[
i
][
1
]
-
rect
[
i
][
0
]
+
1
;
size_t
varSize
=
(
size_t
)
varShape
[
0
]
*
(
size_t
)
varShape
[
1
]
*
(
size_t
)
varShape
[
2
];
xassert
(
varSize
==
(
size_t
)
size
);
if
(
clientIdxlistCache
)
;
else
clientIdxlistCache
=
cdiPioIdxlistCacheNew
(
31
);
Xt_idxlist
(
*
cacheSection
)(
struct
cdiPioIdxlistCache
*
cache
,
const
Xt_int
wholeShape
[],
const
Xt_int
sliceOrigin
[],
const
int
sliceShape
[])
=
(
ndims
==
3
)
?
cdiPioIdxlistCacheAddSection3D
:
cdiPioIdxlistCacheAddSection2D
;
Xt_idxlist
chunkDesc
=
cacheSection
(
clientIdxlistCache
,
varShapeXt
,
origin
,
chunkShape
);
cdiPioBufferPartData
(
streamID
,
varID
,
memtype
,
data
,
nmiss
,
chunkDesc
);
xt_idxlist_delete
(
chunkDesc
);
}
#if defined HAVE_LIBNETCDF
...
...
@@ -243,6 +266,19 @@ cdiPioClientStreamDefTimestep_(stream_t *streamptr, int tsID)
return
cdiStreamDefTimestep_
(
streamptr
,
tsID
);
}
static
void
cdiPioClientVlistDestroy_
(
int
vlistID
,
bool
assertInternal
)
{
if
(
indexOfID
(
&
seenStreamWriteVarChunk
,
vlistID
)
!=
SIZE_MAX
)
{
int
nvars
=
vlistNvars
(
vlistID
);
neededClientIdxlistCacheSize
-=
(
size_t
)
nvars
;
clientIdxlistCache
=
cdiPioIdxlistCacheResize
(
clientIdxlistCache
,
neededClientIdxlistCacheSize
);
removeID
(
&
seenStreamWriteVarChunk
,
vlistID
);
}
cdiVlistDestroy_
(
vlistID
,
assertInternal
);
}
void
cdiPioClientSetup
(
int
pioNamespace
,
struct
cdiPioConf
*
conf
)
{
...
...
@@ -261,6 +297,7 @@ cdiPioClientSetup(int pioNamespace, struct cdiPioConf *conf)
namespaceSwitchSet
(
NSSWITCH_STREAM_CLOSE_BACKEND
,
NSSW_FUNC
(
cdiPioClientStreamClose
));
namespaceSwitchSet
(
NSSWITCH_STREAM_DEF_TIMESTEP_
,
NSSW_FUNC
(
cdiPioClientStreamDefTimestep_
));
namespaceSwitchSet
(
NSSWITCH_STREAM_SYNC
,
NSSW_FUNC
(
cdiPioClientStreamNOP
));
namespaceSwitchSet
(
NSSWITCH_VLIST_DESTROY_
,
NSSW_FUNC
(
cdiPioClientVlistDestroy_
));
#ifdef HAVE_LIBNETCDF
namespaceSwitchSet
(
NSSWITCH_CDF_DEF_TIMESTEP
,
NSSW_FUNC
(
cdiPioCdfDefTimestepNOP
));
namespaceSwitchSet
(
NSSWITCH_CDF_STREAM_SETUP
,
NSSW_FUNC
(
cdiPioClientStreamNOP
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment