Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
darshan
darshan
Commits
f78c456f
Commit
f78c456f
authored
Jan 19, 2016
by
Shane Snyder
Browse files
apply mmap code changes to other i/o modules
parent
d3fae782
Changes
5
Hide whitespace changes
Inline
Side-by-side
darshan-runtime/Makefile.in
View file @
f78c456f
...
...
@@ -23,8 +23,9 @@ DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h
DARSHAN_VERSION
=
@DARSHAN_VERSION@
ifndef
DISABLE_LDPRELOAD
all
:
lib/libdarshan.so
lib/darshan-null.po
all
:
lib/libdarshan.so
endif
#TODO: lib/darshan-null.po
VPATH
=
$(srcdir)
...
...
@@ -34,8 +35,8 @@ CFLAGS_SHARED = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I$(srcdir)
LIBS
=
-lz
@LIBBZ2@
static-mod-objs
=
lib/darshan-posix.o
dynamic-mod-objs
=
lib/darshan-posix.po
static-mod-objs
=
lib/darshan-posix.o
lib/darshan-mpiio.o lib/darshan-hdf5.o lib/darshan-pnetcdf.o
dynamic-mod-objs
=
lib/darshan-posix.po
lib/darshan-mpiio.po lib/darshan-hdf5.po lib/darshan-pnetcdf.po
lib
::
@
mkdir
-p
$@
...
...
darshan-runtime/lib/darshan-hdf5.c
View file @
f78c456f
...
...
@@ -55,12 +55,9 @@ struct hdf5_runtime
{
struct
hdf5_file_runtime
*
file_runtime_array
;
struct
darshan_hdf5_file
*
file_record_array
;
int
file_array_size
;
int
file_array_ndx
;
struct
hdf5_file_runtime
*
file_hash
;
struct
hdf5_file_runtime_ref
*
hid_hash
;
struct
darshan_hdf5_file
*
total_file
;
};
static
struct
hdf5_runtime
*
hdf5_runtime
=
NULL
;
...
...
@@ -205,9 +202,9 @@ static void hdf5_runtime_initialize()
.
get_output_data
=
&
hdf5_get_output_data
,
.
shutdown
=
&
hdf5_shutdown
};
void
*
mmap
_buf
;
int
mmap
_buf_size
;
int
mem_limit
;
void
*
hdf5
_buf
;
int
hdf5
_buf_size
;
int
file_array_size
;
/* don't do anything if already initialized or instrumenation is disabled */
if
(
hdf5_runtime
||
instrumentation_disabled
)
...
...
@@ -217,14 +214,13 @@ static void hdf5_runtime_initialize()
darshan_core_register_module
(
DARSHAN_HDF5_MOD
,
&
hdf5_mod_fns
,
&
hdf5_buf_size
,
&
hdf5_buf
,
&
my_rank
,
&
mem_limit
,
&
mmap_buf
,
&
mmap_buf_size
,
NULL
);
/* return if
no memory assigned by darshan-c
or
e
*/
if
(
mem_limit
==
0
)
/* return if
darshan-core does not provide enough module mem
or
y
*/
if
(
hdf5_buf_size
<
sizeof
(
struct
darshan_hdf5_file
)
)
return
;
hdf5_runtime
=
malloc
(
sizeof
(
*
hdf5_runtime
));
...
...
@@ -232,27 +228,27 @@ static void hdf5_runtime_initialize()
return
;
memset
(
hdf5_runtime
,
0
,
sizeof
(
*
hdf5_runtime
));
/* set
maximum
number of
file records according to max memory limit */
/* NOTE: maximum number of records is based on the size of a hdf5 file record */
/* TODO: should we base memory usage off file record or total runtime structure sizes?
*/
hdf5_runtime
->
file_array_size
=
mem_limit
/
sizeof
(
struct
darshan_hdf5_file
);
/* set number of
trackable files for the HDF5 module according to the
* amount of memory returned by darshan-core
*/
file_array_size
=
hdf5_buf_size
/
sizeof
(
struct
darshan_hdf5_file
);
hdf5_runtime
->
file_array_ndx
=
0
;
/* store pointer to HDF5 record buffer given by darshan-core */
hdf5_runtime
->
file_record_array
=
(
struct
darshan_hdf5_file
*
)
hdf5_buf
;
/* allocate array of runtime file records */
hdf5_runtime
->
file_runtime_array
=
malloc
(
hdf5_runtime
->
file_array_size
*
hdf5_runtime
->
file_runtime_array
=
malloc
(
file_array_size
*
sizeof
(
struct
hdf5_file_runtime
));
/* XXX-MMAP */
hdf5_runtime
->
file_record_array
=
malloc
(
hdf5_runtime
->
file_array_size
*
sizeof
(
struct
darshan_hdf5_file
));
if
(
!
hdf5_runtime
->
file_runtime_array
||
!
hdf5_runtime
->
file_record_array
)
if
(
!
hdf5_runtime
->
file_runtime_array
)
{
hdf5_runtime
->
file_array_size
=
0
;
free
(
hdf5_runtime
);
hdf5_runtime
=
NULL
;
darshan_core_unregister_module
(
DARSHAN_HDF5_MOD
);
return
;
}
memset
(
hdf5_runtime
->
file_runtime_array
,
0
,
hdf5_runtime
->
file_array_size
*
memset
(
hdf5_runtime
->
file_runtime_array
,
0
,
file_array_size
*
sizeof
(
struct
hdf5_file_runtime
));
memset
(
hdf5_runtime
->
file_record_array
,
0
,
hdf5_runtime
->
file_array_size
*
sizeof
(
struct
darshan_hdf5_file
));
return
;
}
...
...
@@ -261,9 +257,10 @@ static void hdf5_runtime_initialize()
static
struct
hdf5_file_runtime
*
hdf5_file_by_name
(
const
char
*
name
)
{
struct
hdf5_file_runtime
*
file
=
NULL
;
struct
darshan_hdf5_file
*
file_rec
;
char
*
newname
=
NULL
;
darshan_record_id
file_id
;
int
limit_flag
;
int
ret
;
if
(
!
hdf5_runtime
||
instrumentation_disabled
)
return
(
NULL
);
...
...
@@ -272,46 +269,36 @@ static struct hdf5_file_runtime* hdf5_file_by_name(const char *name)
if
(
!
newname
)
newname
=
(
char
*
)
name
;
limit_flag
=
(
hdf5_runtime
->
file_array_ndx
>=
hdf5_runtime
->
file_array_size
);
/* get a unique id for this file from darshan core */
darshan_core_register_record
(
/* lookup the unique id for this filename */
darshan_core_lookup_record
(
(
void
*
)
newname
,
strlen
(
newname
),
DARSHAN_HDF5_MOD
,
1
,
limit_flag
,
&
file_id
,
NULL
);
/* if record is set to 0, darshan-core is out of space and will not
* track this record, so we should avoid tracking it, too
*/
if
(
file_id
==
0
)
{
if
(
newname
!=
name
)
free
(
newname
);
return
(
NULL
);
}
&
file_id
);
/* search the hash table for this file record, and return if found */
HASH_FIND
(
hlink
,
hdf5_runtime
->
file_hash
,
&
file_id
,
sizeof
(
darshan_record_id
),
file
);
if
(
file
)
if
(
!
file
)
{
if
(
newname
!=
name
)
free
(
newname
);
return
(
file
);
}
/* register the record with the darshan core component */
ret
=
darshan_core_register_record
(
file_id
,
(
void
*
)
newname
,
DARSHAN_HDF5_MOD
,
sizeof
(
struct
darshan_hdf5_file
),
NULL
);
if
(
ret
==
1
)
{
/* register was successful */
file
=
&
(
hdf5_runtime
->
file_runtime_array
[
hdf5_runtime
->
file_array_ndx
]);
file
->
file_record
=
&
(
hdf5_runtime
->
file_record_array
[
hdf5_runtime
->
file_array_ndx
]);
file_rec
=
file
->
file_record
;
/* no existing record, assign a new file record from the global array */
file
=
&
(
hdf5_runtime
->
file_runtime_array
[
hdf5_runtime
->
file_array_ndx
]);
file
->
file_record
=
&
(
hdf5_runtime
->
file_record_array
[
hdf5_runtime
->
file_array_ndx
]);
file
->
file_record
->
f_id
=
file_id
;
file
->
file_record
->
rank
=
my_rank
;
file_rec
->
base_rec
.
id
=
file_id
;
file_rec
->
base_rec
.
rank
=
my_rank
;
/* add new record to file hash table */
HASH_ADD
(
hlink
,
hdf5_runtime
->
file_hash
,
file_record
->
f_id
,
sizeof
(
darshan_record_id
),
file
);
hdf5_runtime
->
file_array_ndx
++
;
/* add new record to file hash table */
HASH_ADD
(
hlink
,
hdf5_runtime
->
file_hash
,
file_record
->
base_rec
.
id
,
sizeof
(
darshan_record_id
),
file
);
hdf5_runtime
->
file_array_ndx
++
;
}
}
if
(
newname
!=
name
)
free
(
newname
);
...
...
@@ -403,9 +390,9 @@ static int hdf5_record_compare(const void* a_p, const void* b_p)
const
struct
darshan_hdf5_file
*
a
=
a_p
;
const
struct
darshan_hdf5_file
*
b
=
b_p
;
if
(
a
->
rank
<
b
->
rank
)
if
(
a
->
base_rec
.
rank
<
b
->
base_rec
.
rank
)
return
1
;
if
(
a
->
rank
>
b
->
rank
)
if
(
a
->
base_rec
.
rank
>
b
->
base_rec
.
rank
)
return
-
1
;
return
0
;
...
...
@@ -424,8 +411,8 @@ static void hdf5_record_reduction_op(void* infile_v, void* inoutfile_v,
for
(
i
=
0
;
i
<*
len
;
i
++
)
{
memset
(
&
tmp_file
,
0
,
sizeof
(
struct
darshan_hdf5_file
));
tmp_file
.
f_
id
=
infile
->
f_
id
;
tmp_file
.
rank
=
-
1
;
tmp_file
.
base_rec
.
id
=
infile
->
base_rec
.
id
;
tmp_file
.
base_rec
.
rank
=
-
1
;
/* sum */
for
(
j
=
HDF5_OPENS
;
j
<=
HDF5_OPENS
;
j
++
)
...
...
@@ -505,7 +492,7 @@ static void hdf5_get_output_data(
sizeof
(
darshan_record_id
),
file
);
assert
(
file
);
file
->
file_record
->
rank
=
-
1
;
file
->
file_record
->
base_rec
.
rank
=
-
1
;
}
/* sort the array of files descending by rank so that we get all of the
...
...
darshan-runtime/lib/darshan-mpiio.c
View file @
f78c456f
...
...
@@ -99,12 +99,9 @@ struct mpiio_runtime
{
struct
mpiio_file_runtime
*
file_runtime_array
;
struct
darshan_mpiio_file
*
file_record_array
;
int
file_array_size
;
int
file_array_ndx
;
struct
mpiio_file_runtime
*
file_hash
;
struct
mpiio_file_runtime_ref
*
fh_hash
;
struct
darshan_mpiio_file
*
total_file
;
};
static
struct
mpiio_runtime
*
mpiio_runtime
=
NULL
;
...
...
@@ -828,26 +825,28 @@ static void mpiio_runtime_initialize()
.
get_output_data
=
&
mpiio_get_output_data
,
.
shutdown
=
&
mpiio_shutdown
};
void
*
m
map
_buf
;
int
m
map
_buf_size
;
int
mem_limit
;
void
*
m
piio
_buf
;
int
m
piio
_buf_size
;
int
file_array_size
;
/* don't do anything if already initialized or instrumenation is disabled */
if
(
mpiio_runtime
||
instrumentation_disabled
)
return
;
/* try and store the default number of records for this module */
mpiio_buf_size
=
DARSHAN_DEF_MOD_REC_COUNT
*
sizeof
(
struct
darshan_mpiio_file
);
/* register the mpiio module with darshan core */
darshan_core_register_module
(
DARSHAN_MPIIO_MOD
,
&
mpiio_mod_fns
,
&
mpiio_buf_size
,
&
mpiio_buf
,
&
my_rank
,
&
mem_limit
,
&
mmap_buf
,
&
mmap_buf_size
,
NULL
);
/* return if
no memory assigned by darshan c
or
e
*/
if
(
m
em_limit
==
0
)
/* return if
darshan-core does not provide enough module mem
or
y
*/
if
(
m
piio_buf_size
<
sizeof
(
struct
darshan_mpiio_file
)
)
return
;
mpiio_runtime
=
malloc
(
sizeof
(
*
mpiio_runtime
));
...
...
@@ -855,25 +854,27 @@ static void mpiio_runtime_initialize()
return
;
memset
(
mpiio_runtime
,
0
,
sizeof
(
*
mpiio_runtime
));
/* set maximum number of file records according to max memory limit */
/* NOTE: maximum number of records is based on the size of a mpiio file record */
mpiio_runtime
->
file_array_size
=
mem_limit
/
sizeof
(
struct
darshan_mpiio_file
);
/* set number of trackable files for the MPIIO module according to the
* amount of memory returned by darshan-core
*/
file_array_size
=
mpiio_buf_size
/
sizeof
(
struct
darshan_mpiio_file
);
mpiio_runtime
->
file_array_ndx
=
0
;
/* store pointer to MPIIO record buffer given by darshan-core */
mpiio_runtime
->
file_record_array
=
(
struct
darshan_mpiio_file
*
)
mpiio_buf
;
/* allocate array of runtime file records */
mpiio_runtime
->
file_runtime_array
=
malloc
(
mpiio_runtime
->
file_array_size
*
mpiio_runtime
->
file_runtime_array
=
malloc
(
file_array_size
*
sizeof
(
struct
mpiio_file_runtime
));
mpiio_runtime
->
file_record_array
=
malloc
(
mpiio_runtime
->
file_array_size
*
sizeof
(
struct
darshan_mpiio_file
));
if
(
!
mpiio_runtime
->
file_runtime_array
||
!
mpiio_runtime
->
file_record_array
)
if
(
!
mpiio_runtime
->
file_runtime_array
)
{
mpiio_runtime
->
file_array_size
=
0
;
free
(
mpiio_runtime
);
mpiio_runtime
=
NULL
;
darshan_core_unregister_module
(
DARSHAN_MPIIO_MOD
);
return
;
}
memset
(
mpiio_runtime
->
file_runtime_array
,
0
,
mpiio_runtime
->
file_array_size
*
memset
(
mpiio_runtime
->
file_runtime_array
,
0
,
file_array_size
*
sizeof
(
struct
mpiio_file_runtime
));
memset
(
mpiio_runtime
->
file_record_array
,
0
,
mpiio_runtime
->
file_array_size
*
sizeof
(
struct
darshan_mpiio_file
));
return
;
}
...
...
@@ -882,9 +883,10 @@ static void mpiio_runtime_initialize()
static
struct
mpiio_file_runtime
*
mpiio_file_by_name
(
const
char
*
name
)
{
struct
mpiio_file_runtime
*
file
=
NULL
;
struct
darshan_mpiio_file
*
file_rec
;
char
*
newname
=
NULL
;
darshan_record_id
file_id
;
int
limit_flag
;
int
ret
;
if
(
!
mpiio_runtime
||
instrumentation_disabled
)
return
(
NULL
);
...
...
@@ -893,46 +895,36 @@ static struct mpiio_file_runtime* mpiio_file_by_name(const char *name)
if
(
!
newname
)
newname
=
(
char
*
)
name
;
limit_flag
=
(
mpiio_runtime
->
file_array_ndx
>=
mpiio_runtime
->
file_array_size
);
/* get a unique id for this file from darshan core */
darshan_core_register_record
(
/* lookup the unique id for this filename */
darshan_core_lookup_record
(
(
void
*
)
newname
,
strlen
(
newname
),
DARSHAN_MPIIO_MOD
,
1
,
limit_flag
,
&
file_id
,
NULL
);
/* the file record id is set to 0 if no memory is available for tracking
* new records -- just fall through and ignore this record
*/
if
(
file_id
==
0
)
{
if
(
newname
!=
name
)
free
(
newname
);
return
(
NULL
);
}
&
file_id
);
/* search the hash table for this file record, and return if found */
HASH_FIND
(
hlink
,
mpiio_runtime
->
file_hash
,
&
file_id
,
sizeof
(
darshan_record_id
),
file
);
if
(
file
)
if
(
!
file
)
{
if
(
newname
!=
name
)
free
(
newname
);
return
(
file
);
}
/* register the record with the darshan core component */
ret
=
darshan_core_register_record
(
file_id
,
(
void
*
)
newname
,
DARSHAN_MPIIO_MOD
,
sizeof
(
struct
darshan_mpiio_file
),
NULL
);
if
(
ret
==
1
)
{
/* register was successful */
file
=
&
(
mpiio_runtime
->
file_runtime_array
[
mpiio_runtime
->
file_array_ndx
]);
file
->
file_record
=
&
(
mpiio_runtime
->
file_record_array
[
mpiio_runtime
->
file_array_ndx
]);
file_rec
=
file
->
file_record
;
/* no existing record, assign a new file record from the global array */
file
=
&
(
mpiio_runtime
->
file_runtime_array
[
mpiio_runtime
->
file_array_ndx
]);
file
->
file_record
=
&
(
mpiio_runtime
->
file_record_array
[
mpiio_runtime
->
file_array_ndx
]);
file
->
file_record
->
f_id
=
file_id
;
file
->
file_record
->
rank
=
my_rank
;
file_rec
->
base_rec
.
id
=
file_id
;
file_rec
->
base_rec
.
rank
=
my_rank
;
/* add new record to file hash table */
HASH_ADD
(
hlink
,
mpiio_runtime
->
file_hash
,
file_record
->
f_id
,
sizeof
(
darshan_record_id
),
file
);
mpiio_runtime
->
file_array_ndx
++
;
/* add new record to file hash table */
HASH_ADD
(
hlink
,
mpiio_runtime
->
file_hash
,
file_record
->
base_rec
.
id
,
sizeof
(
darshan_record_id
),
file
);
mpiio_runtime
->
file_array_ndx
++
;
}
}
if
(
newname
!=
name
)
free
(
newname
);
...
...
@@ -1024,9 +1016,9 @@ static int mpiio_record_compare(const void* a_p, const void* b_p)
const
struct
darshan_mpiio_file
*
a
=
a_p
;
const
struct
darshan_mpiio_file
*
b
=
b_p
;
if
(
a
->
rank
<
b
->
rank
)
if
(
a
->
base_rec
.
rank
<
b
->
base_rec
.
rank
)
return
1
;
if
(
a
->
rank
>
b
->
rank
)
if
(
a
->
base_rec
.
rank
>
b
->
base_rec
.
rank
)
return
-
1
;
return
0
;
...
...
@@ -1048,9 +1040,8 @@ static void mpiio_record_reduction_op(
for
(
i
=
0
;
i
<*
len
;
i
++
)
{
memset
(
&
tmp_file
,
0
,
sizeof
(
struct
darshan_mpiio_file
));
tmp_file
.
f_id
=
infile
->
f_id
;
tmp_file
.
rank
=
-
1
;
tmp_file
.
base_rec
.
id
=
infile
->
base_rec
.
id
;
tmp_file
.
base_rec
.
rank
=
-
1
;
/* sum */
for
(
j
=
MPIIO_INDEP_OPENS
;
j
<=
MPIIO_VIEWS
;
j
++
)
...
...
@@ -1358,7 +1349,7 @@ static void mpiio_get_output_data(
/* initialize fastest/slowest info prior to the reduction */
file
->
file_record
->
counters
[
MPIIO_FASTEST_RANK
]
=
file
->
file_record
->
rank
;
file
->
file_record
->
base_rec
.
rank
;
file
->
file_record
->
counters
[
MPIIO_FASTEST_RANK_BYTES
]
=
file
->
file_record
->
counters
[
MPIIO_BYTES_READ
]
+
file
->
file_record
->
counters
[
MPIIO_BYTES_WRITTEN
];
...
...
@@ -1376,7 +1367,7 @@ static void mpiio_get_output_data(
file
->
file_record
->
fcounters
[
MPIIO_F_SLOWEST_RANK_TIME
]
=
file
->
file_record
->
fcounters
[
MPIIO_F_FASTEST_RANK_TIME
];
file
->
file_record
->
rank
=
-
1
;
file
->
file_record
->
base_rec
.
rank
=
-
1
;
}
/* sort the array of files descending by rank so that we get all of the
...
...
@@ -1454,7 +1445,6 @@ static void mpiio_shutdown()
HASH_CLEAR
(
hlink
,
mpiio_runtime
->
file_hash
);
/* these entries are freed all at once below */
free
(
mpiio_runtime
->
file_runtime_array
);
free
(
mpiio_runtime
->
file_record_array
);
free
(
mpiio_runtime
);
mpiio_runtime
=
NULL
;
...
...
darshan-runtime/lib/darshan-pnetcdf.c
View file @
f78c456f
...
...
@@ -51,12 +51,9 @@ struct pnetcdf_runtime
{
struct
pnetcdf_file_runtime
*
file_runtime_array
;
struct
darshan_pnetcdf_file
*
file_record_array
;
int
file_array_size
;
int
file_array_ndx
;
struct
pnetcdf_file_runtime
*
file_hash
;
struct
pnetcdf_file_runtime_ref
*
ncid_hash
;
struct
darshan_pnetcdf_file
*
total_file
;
};
static
struct
pnetcdf_runtime
*
pnetcdf_runtime
=
NULL
;
...
...
@@ -217,26 +214,28 @@ static void pnetcdf_runtime_initialize()
.
get_output_data
=
&
pnetcdf_get_output_data
,
.
shutdown
=
&
pnetcdf_shutdown
};
void
*
mmap
_buf
;
int
mmap
_buf_size
;
int
mem_limit
;
void
*
pnetcdf
_buf
;
int
pnetcdf
_buf_size
;
int
file_array_size
;
/* don't do anything if already initialized or instrumenation is disabled */
if
(
pnetcdf_runtime
||
instrumentation_disabled
)
return
;
/* try and store the default number of records for this module */
pnetcdf_buf_size
=
DARSHAN_DEF_MOD_REC_COUNT
*
sizeof
(
struct
darshan_pnetcdf_file
);
/* register pnetcdf module with darshan-core */
darshan_core_register_module
(
DARSHAN_PNETCDF_MOD
,
&
pnetcdf_mod_fns
,
&
pnetcdf_buf_size
,
&
pnetcdf_buf
,
&
my_rank
,
&
mem_limit
,
&
mmap_buf
,
&
mmap_buf_size
,
NULL
);
/* return if
no memory assigned by darshan-c
or
e
*/
if
(
mem_limit
==
0
)
/* return if
darshan-core does not provide enough module mem
or
y
*/
if
(
pnetcdf_buf_size
<
sizeof
(
struct
darshan_pnetcdf_file
)
)
return
;
pnetcdf_runtime
=
malloc
(
sizeof
(
*
pnetcdf_runtime
));
...
...
@@ -244,27 +243,27 @@ static void pnetcdf_runtime_initialize()
return
;
memset
(
pnetcdf_runtime
,
0
,
sizeof
(
*
pnetcdf_runtime
));
/* set
maximum
number of
file records according to max memory limit */
/* NOTE: maximum number of records is based on the size of a pnetcdf file record */
/* TODO: should we base memory usage off file record or total runtime structure sizes?
*/
pnetcdf_runtime
->
file_array_size
=
mem_limit
/
sizeof
(
struct
darshan_pnetcdf_file
);
/* set number of
trackable files for the PNETCDF module according to the
* amount of memory returned by darshan-core
*/
file_array_size
=
pnetcdf_buf_size
/
sizeof
(
struct
darshan_pnetcdf_file
);
pnetcdf_runtime
->
file_array_ndx
=
0
;
/* store pointer to PNETCDF record buffer given by darshan-core */
pnetcdf_runtime
->
file_record_array
=
(
struct
darshan_pnetcdf_file
*
)
pnetcdf_buf
;
/* allocate array of runtime file records */
pnetcdf_runtime
->
file_runtime_array
=
malloc
(
pnetcdf_runtime
->
file_array_size
*
pnetcdf_runtime
->
file_runtime_array
=
malloc
(
file_array_size
*
sizeof
(
struct
pnetcdf_file_runtime
));
/* XXX-MMAP */
pnetcdf_runtime
->
file_record_array
=
malloc
(
pnetcdf_runtime
->
file_array_size
*
sizeof
(
struct
darshan_pnetcdf_file
));
if
(
!
pnetcdf_runtime
->
file_runtime_array
||
!
pnetcdf_runtime
->
file_record_array
)
if
(
!
pnetcdf_runtime
->
file_runtime_array
)
{
pnetcdf_runtime
->
file_array_size
=
0
;
free
(
pnetcdf_runtime
);
pnetcdf_runtime
=
NULL
;
darshan_core_unregister_module
(
DARSHAN_PNETCDF_MOD
);
return
;
}
memset
(
pnetcdf_runtime
->
file_runtime_array
,
0
,
pnetcdf_runtime
->
file_array_size
*
memset
(
pnetcdf_runtime
->
file_runtime_array
,
0
,
file_array_size
*
sizeof
(
struct
pnetcdf_file_runtime
));
memset
(
pnetcdf_runtime
->
file_record_array
,
0
,
pnetcdf_runtime
->
file_array_size
*
sizeof
(
struct
darshan_pnetcdf_file
));
return
;
}
...
...
@@ -273,9 +272,10 @@ static void pnetcdf_runtime_initialize()
static
struct
pnetcdf_file_runtime
*
pnetcdf_file_by_name
(
const
char
*
name
)
{
struct
pnetcdf_file_runtime
*
file
=
NULL
;
struct
darshan_pnetcdf_file
*
file_rec
;
char
*
newname
=
NULL
;
darshan_record_id
file_id
;
int
limit_flag
;
int
ret
;
if
(
!
pnetcdf_runtime
||
instrumentation_disabled
)
return
(
NULL
);
...
...
@@ -284,46 +284,36 @@ static struct pnetcdf_file_runtime* pnetcdf_file_by_name(const char *name)
if
(
!
newname
)
newname
=
(
char
*
)
name
;
limit_flag
=
(
pnetcdf_runtime
->
file_array_ndx
>=
pnetcdf_runtime
->
file_array_size
);
/* get a unique id for this file from darshan core */
darshan_core_register_record
(
/* lookup the unique id for this filename */
darshan_core_lookup_record
(
(
void
*
)
newname
,
strlen
(
newname
),
DARSHAN_PNETCDF_MOD
,
1
,
limit_flag
,
&
file_id
,
NULL
);
/* the file record id is set to 0 if no memory is available for tracking
* new records -- just fall through and ignore this record
*/
if
(
file_id
==
0
)
{
if
(
newname
!=
name
)
free
(
newname
);
return
(
NULL
);
}
&
file_id
);
/* search the hash table for this file record, and return if found */
HASH_FIND
(
hlink
,
pnetcdf_runtime
->
file_hash
,
&
file_id
,
sizeof
(
darshan_record_id
),
file
);
if
(
file
)
if
(
!
file
)
{
if
(
newname
!=
name
)
free
(
newname
);
return
(
file
);
}
/* register the record with the darshan core component */
ret
=
darshan_core_register_record
(
file_id
,
(
void
*
)
newname
,
DARSHAN_PNETCDF_MOD
,
sizeof
(
struct
darshan_pnetcdf_file
),
NULL
);
if
(
ret
==
1
)
{
/* register was successful */
file
=
&
(
pnetcdf_runtime
->
file_runtime_array
[
pnetcdf_runtime
->
file_array_ndx
]);
file
->
file_record
=
&
(
pnetcdf_runtime
->
file_record_array
[
pnetcdf_runtime
->
file_array_ndx
]);
file_rec
=
file
->
file_record
;
/* no existing record, assign a new file record from the global array */
file
=
&
(
pnetcdf_runtime
->
file_runtime_array
[
pnetcdf_runtime
->
file_array_ndx
]);
file
->
file_record
=
&
(
pnetcdf_runtime
->
file_record_array
[
pnetcdf_runtime
->
file_array_ndx
]);
file
->
file_record
->
f_id
=
file_id
;
file
->
file_record
->
rank
=
my_rank
;
file_rec
->
base_rec
.
id
=
file_id
;
file_rec
->
base_rec
.
rank
=
my_rank
;
/* add new record to file hash table */
HASH_ADD
(
hlink
,
pnetcdf_runtime
->
file_hash
,
file_record
->
f_id
,
sizeof
(
darshan_record_id
),
file
);
pnetcdf_runtime
->
file_array_ndx
++
;
/* add new record to file hash table */
HASH_ADD
(
hlink
,
pnetcdf_runtime
->
file_hash
,
file_record
->
base_rec
.
id
,
sizeof
(
darshan_record_id
),
file
);
pnetcdf_runtime
->
file_array_ndx
++
;
}
}
if
(
newname
!=
name
)
free
(
newname
);
...
...
@@ -415,9 +405,9 @@ static int pnetcdf_record_compare(const void* a_p, const void* b_p)
const
struct
darshan_pnetcdf_file
*
a
=
a_p
;
const
struct
darshan_pnetcdf_file
*
b
=
b_p
;
if
(
a
->
rank
<
b
->
rank
)
if
(
a
->
base_rec
.
rank
<
b
->
base_rec
.
rank
)
return
1
;
if
(
a
->
rank
>
b
->
rank
)
if
(
a
->
base_rec
.
rank
>
b
->