Skip to content

Commit 8538154

Browse files
author
Shane Snyder
committed
update pnetcdf_var_runtime to use varid_hash
* `ncid_hash` name was confusing, so just add a new runtime structure for variables that defines a `varid_hash` instead.
1 parent 8e9f26b commit 8538154

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

darshan-runtime/lib/darshan-pnetcdf-api.m4

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ int DARSHAN_DECL(APINAME($1,$2,$3,$4))(int ncid, int varid, ArgKind($2)BufArgs($
234234
if (ret == NC_NOERR) {
235235
PNETCDF_VAR_PRE_RECORD();
236236
struct pnetcdf_var_record_ref *rec_ref;
237-
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->ncid_hash, &varid, sizeof(int));
237+
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->varid_hash, &varid, sizeof(int));
238238
if (rec_ref) {
239239
struct darshan_common_val_counter *cvc;
240240
int64_t common_access_vals[PNETCDF_VAR_MAX_NDIMS+PNETCDF_VAR_MAX_NDIMS+1] = {0};
@@ -277,7 +277,7 @@ int DARSHAN_DECL(APINAME($1,n,$2,$3))(int ncid, int varid, int num, MPI_Offset*
277277
if (ret == NC_NOERR) {
278278
PNETCDF_VAR_PRE_RECORD();
279279
struct pnetcdf_var_record_ref *rec_ref;
280-
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->ncid_hash, &varid, sizeof(int));
280+
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->varid_hash, &varid, sizeof(int));
281281
if (rec_ref) {
282282
struct darshan_common_val_counter *cvc;
283283
int64_t common_access_vals[PNETCDF_VAR_MAX_NDIMS+PNETCDF_VAR_MAX_NDIMS+1] = {0};
@@ -319,7 +319,7 @@ int DARSHAN_DECL(ncmpi_$1_vard$2)(int ncid, int varid, MPI_Datatype filetype, if
319319
if (ret == NC_NOERR) {
320320
PNETCDF_VAR_PRE_RECORD();
321321
struct pnetcdf_var_record_ref *rec_ref;
322-
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->ncid_hash, &varid, sizeof(int));
322+
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->varid_hash, &varid, sizeof(int));
323323
if (rec_ref) {
324324
struct darshan_common_val_counter *cvc;
325325
int64_t common_access_vals[PNETCDF_VAR_MAX_NDIMS+PNETCDF_VAR_MAX_NDIMS+1] = {0};
@@ -360,7 +360,7 @@ int DARSHAN_DECL(APINAME($1,$2,$3))(int ncid, int varid, ArgKind($2)BufArgs($1,$
360360
if (ret == NC_NOERR) {
361361
PNETCDF_VAR_PRE_RECORD();
362362
struct pnetcdf_var_record_ref *rec_ref;
363-
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->ncid_hash, &varid, sizeof(int));
363+
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->varid_hash, &varid, sizeof(int));
364364
if (rec_ref) {
365365
struct darshan_common_val_counter *cvc;
366366
int64_t common_access_vals[PNETCDF_VAR_MAX_NDIMS+PNETCDF_VAR_MAX_NDIMS+1] = {0};
@@ -404,7 +404,7 @@ int DARSHAN_DECL(APINAME($1,n,$2))(int ncid, int varid, int num, MPI_Offset* con
404404
if (ret == NC_NOERR) {
405405
PNETCDF_VAR_PRE_RECORD();
406406
struct pnetcdf_var_record_ref *rec_ref;
407-
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->ncid_hash, &varid, sizeof(int));
407+
rec_ref = darshan_lookup_record_ref(pnetcdf_var_runtime->varid_hash, &varid, sizeof(int));
408408
if (rec_ref) {
409409
struct darshan_common_val_counter *cvc;
410410
int64_t common_access_vals[PNETCDF_VAR_MAX_NDIMS+PNETCDF_VAR_MAX_NDIMS+1] = {0};
@@ -781,7 +781,7 @@ define(`PNETCDF_VAR_RECORD_OPEN',`
781781
else type_size = 8;
782782
rec_ref->var_rec->counters[PNETCDF_VAR_DATATYPE_SIZE] = type_size;
783783
rec_ref->var_rec->file_rec_id = file_rec_id;
784-
darshan_add_record_ref(&(pnetcdf_var_runtime->ncid_hash), $6, sizeof(int), rec_ref);
784+
darshan_add_record_ref(&(pnetcdf_var_runtime->varid_hash), $6, sizeof(int), rec_ref);
785785
} while (0);
786786
')dnl
787787

darshan-runtime/lib/darshan-pnetcdf.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,24 @@ struct pnetcdf_var_record_ref
5050
int unlimdimid;
5151
};
5252

53-
/* struct to encapsulate runtime state for the PnetCDF module */
54-
struct pnetcdf_runtime
53+
/* struct to encapsulate runtime state for the PnetCDF file module */
54+
struct pnetcdf_file_runtime
5555
{
5656
void *rec_id_hash;
5757
void *ncid_hash;
5858
int rec_count;
5959
int frozen; /* flag to indicate that the counters should no longer be modified */
6060
};
6161

62+
/* struct to encapsulate runtime state for the PnetCDF var module */
63+
struct pnetcdf_var_runtime
64+
{
65+
void *rec_id_hash;
66+
void *varid_hash;
67+
int rec_count;
68+
int frozen; /* flag to indicate that the counters should no longer be modified */
69+
};
70+
6271
static void pnetcdf_file_runtime_initialize(void);
6372
static void pnetcdf_var_runtime_initialize(void);
6473
static struct pnetcdf_file_record_ref *pnetcdf_file_track_new_record(
@@ -87,9 +96,9 @@ static void pnetcdf_var_output(
8796
static void pnetcdf_file_cleanup(void);
8897
static void pnetcdf_var_cleanup(void);
8998

90-
static struct pnetcdf_runtime *pnetcdf_file_runtime = NULL;
99+
static struct pnetcdf_file_runtime *pnetcdf_file_runtime = NULL;
91100
static int pnetcdf_file_runtime_init_attempted = 0;
92-
static struct pnetcdf_runtime *pnetcdf_var_runtime = NULL;
101+
static struct pnetcdf_var_runtime *pnetcdf_var_runtime = NULL;
93102
static int pnetcdf_var_runtime_init_attempted = 0;
94103

95104
static pthread_mutex_t pnetcdf_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
@@ -180,7 +189,7 @@ static void pnetcdf_file_runtime_initialize()
180189
if(ret < 0)
181190
return;
182191

183-
pnetcdf_file_runtime = (struct pnetcdf_runtime*) calloc(1, sizeof(struct pnetcdf_runtime));
192+
pnetcdf_file_runtime = (struct pnetcdf_file_runtime*) calloc(1, sizeof(struct pnetcdf_file_runtime));
184193
if(!pnetcdf_file_runtime)
185194
{
186195
darshan_core_unregister_module(DARSHAN_PNETCDF_FILE_MOD);
@@ -218,7 +227,7 @@ static void pnetcdf_var_runtime_initialize()
218227
if(ret < 0)
219228
return;
220229

221-
pnetcdf_var_runtime = (struct pnetcdf_runtime*) calloc(1, sizeof(struct pnetcdf_runtime));
230+
pnetcdf_var_runtime = (struct pnetcdf_var_runtime*) calloc(1, sizeof(struct pnetcdf_var_runtime));
222231
if(!pnetcdf_var_runtime)
223232
{
224233
darshan_core_unregister_module(DARSHAN_PNETCDF_VAR_MOD);
@@ -927,7 +936,7 @@ static void pnetcdf_var_cleanup(void)
927936
&pnetcdf_var_finalize_records, NULL);
928937

929938
/* cleanup internal structures used for instrumenting */
930-
darshan_clear_record_refs(&(pnetcdf_var_runtime->ncid_hash), 0);
939+
darshan_clear_record_refs(&(pnetcdf_var_runtime->varid_hash), 0);
931940
darshan_clear_record_refs(&(pnetcdf_var_runtime->rec_id_hash), 1);
932941

933942
free(pnetcdf_var_runtime);

0 commit comments

Comments
 (0)