Commit 72380aad authored by Shane Snyder's avatar Shane Snyder

more docs and added unregister functions

parent acc05e4a
......@@ -63,12 +63,15 @@ void darshan_core_register_module(
struct darshan_module_funcs *funcs,
int *runtime_mem_limit);
void darshan_core_unregister_module(
darshan_module_id mod_id);
void darshan_core_register_record(
void *name,
int len,
int printable_flag,
darshan_module_id mod_id,
darshan_record_id *id);
darshan_record_id *rec_id);
void darshan_core_unregister_record(
darshan_record_id rec_id,
......
......@@ -32,7 +32,7 @@ extern char* __progname;
/* internal variable delcarations */
static struct darshan_core_runtime *darshan_core = NULL;
static pthread_mutex_t darshan_core_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t darshan_core_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int my_rank = -1;
static int nprocs = -1;
......@@ -1484,19 +1484,19 @@ static int darshan_log_coll_write(MPI_File log_fh, void *buf, int count,
/* ********************************************************* */
void darshan_core_register_module(
darshan_module_id id,
darshan_module_id mod_id,
struct darshan_module_funcs *funcs,
int *runtime_mem_limit)
{
struct darshan_core_module* mod;
*runtime_mem_limit = 0;
if(!darshan_core || (id >= DARSHAN_MAX_MODS))
if(!darshan_core || (mod_id >= DARSHAN_MAX_MODS))
return;
/* see if this module is already registered */
DARSHAN_CORE_LOCK();
if(darshan_core->mod_array[id])
if(darshan_core->mod_array[mod_id])
{
/* if module is already registered just return */
/* NOTE: we do not recalculate memory limit here, just set to 0 */
......@@ -1513,11 +1513,11 @@ void darshan_core_register_module(
}
memset(mod, 0, sizeof(*mod));
mod->id = id;
mod->id = mod_id;
mod->mod_funcs = *funcs;
/* register module with darshan */
darshan_core->mod_array[id] = mod;
darshan_core->mod_array[mod_id] = mod;
/* TODO: something smarter than just 2 MiB per module */
*runtime_mem_limit = 2 * 1024 * 1024;
......@@ -1527,6 +1527,31 @@ void darshan_core_register_module(
return;
}
/* TODO: implement & test*/
void darshan_core_unregister_module(
darshan_module_id mod_id)
{
struct darshan_core_record_ref *ref, *tmp;
if(!darshan_core)
return;
DARSHAN_CORE_LOCK();
/* iterate all records and disassociate this module from them */
HASH_ITER(hlink, darshan_core->rec_hash, ref, tmp)
{
darshan_core_unregister_record(ref->rec.id, mod_id);
}
free(darshan_core->mod_array[mod_id]);
darshan_core->mod_array[mod_id] = NULL;
DARSHAN_CORE_UNLOCK();
return;
}
void darshan_core_register_record(
void *name,
int len,
......@@ -1579,6 +1604,7 @@ void darshan_core_register_record(
return;
}
/* TODO: test */
void darshan_core_unregister_record(
darshan_record_id rec_id,
darshan_module_id mod_id)
......
......@@ -103,6 +103,7 @@ static pthread_mutex_t posix_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER
static int instrumentation_disabled = 0;
static int my_rank = -1;
/* TODO: I'm sure these should be applied on all modules */
/* these are paths that we will not trace */
static char* exclusions[] = {
"/etc/",
......
......@@ -362,7 +362,6 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
}
free(comp_buf);
/* TODO: check for duplicate entries? */
buf_ptr = hash_buf;
while(buf_ptr < (hash_buf + hash_buf_sz))
{
......@@ -377,18 +376,6 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
path_ptr = (char *)buf_ptr;
buf_ptr += *path_len_ptr;
ref = malloc(sizeof(*ref));
if(!ref)
{
return(-1);
}
ref->rec.name = malloc(*path_len_ptr + 1);
if(!ref->rec.name)
{
free(ref);
return(-1);
}
if(fd->swap_flag)
{
/* we need to sort out endianness issues before deserializing */
......@@ -396,13 +383,29 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
DARSHAN_BSWAP32(path_len_ptr);
}
/* set the fields for this record */
ref->rec.id = *rec_id_ptr;
memcpy(ref->rec.name, path_ptr, *path_len_ptr);
ref->rec.name[*path_len_ptr] = '\0';
HASH_FIND(hlink, *hash, rec_id_ptr, sizeof(darshan_record_id), ref);
if(!ref)
{
ref = malloc(sizeof(*ref));
if(!ref)
{
return(-1);
}
ref->rec.name = malloc(*path_len_ptr + 1);
if(!ref->rec.name)
{
free(ref);
return(-1);
}
/* set the fields for this record */
ref->rec.id = *rec_id_ptr;
memcpy(ref->rec.name, path_ptr, *path_len_ptr);
ref->rec.name[*path_len_ptr] = '\0';
/* add this record to the hash */
HASH_ADD(hlink, *hash, rec.id, sizeof(darshan_record_id), ref);
/* add this record to the hash */
HASH_ADD(hlink, *hash, rec.id, sizeof(darshan_record_id), ref);
}
}
return(0);
......@@ -476,15 +479,13 @@ int darshan_log_getmod(darshan_fd fd, darshan_module_id mod_id,
*mod_buf = tmp_buf;
*mod_buf_sz = tmp_buf_sz;
/* TODO: bswaps */
return(0);
}
#if 0
/* TODO: hardcoded for posix -- what can we do generally?
* different function for each module and a way to map to this function?
*/
/* TODO: we need bswaps here, too */
int darshan_log_getfile(darshan_fd fd, struct darshan_posix_file *file)
{
char *comp_buf;
......@@ -544,7 +545,6 @@ int darshan_log_getfile(darshan_fd fd, struct darshan_posix_file *file)
fprintf(stderr, "Error: %s\n", err_string);
return(-1);
}
#endif
/* darshan_log_close()
*
......@@ -563,7 +563,7 @@ void darshan_log_close(darshan_fd fd)
free(fd);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* ******************************************* */
/* return 0 on successful seek to offset, -1 on failure.
*/
......
......@@ -168,11 +168,18 @@ int main(int argc, char **argv)
return(0);
}
/* TODO: move this functionality somewhere else so it can be reused */
/* loop over the POSIX file records and print out counters */
for(i = 0; i < (posix_mod_buf_sz / sizeof(struct darshan_posix_file)); i++)
{
struct darshan_posix_file next_rec = posix_mod_buf[i];
DARSHAN_BSWAP64(&(next_rec.f_id));
DARSHAN_BSWAP64(&(next_rec.rank));
DARSHAN_BSWAP64(&(next_rec.counters[CP_POSIX_OPENS]));
DARSHAN_BSWAP64(&(next_rec.fcounters[CP_F_OPEN_TIMESTAMP]));
DARSHAN_BSWAP64(&(next_rec.fcounters[CP_F_CLOSE_TIMESTAMP]));
/* get the pathname for this record */
HASH_FIND(hlink, rec_hash, &next_rec.f_id, sizeof(darshan_record_id), ref);
assert(ref);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment