Commit c3a85a3e authored by Shane Snyder's avatar Shane Snyder

switch lustre to use array instead of hash table

parent fdf5af2d
...@@ -22,27 +22,16 @@ ...@@ -22,27 +22,16 @@
#include "darshan.h" #include "darshan.h"
#include "darshan-dynamic.h" #include "darshan-dynamic.h"
/* TODO: once mmap merge is complete, we can just use an array /* we just use a simple array for storing records. the POSIX module
* to store record data rather than a hash table -- in that * only calls into the Lustre module for new records, so we will never
* branch, register_record() returns whether the record * have to search for an existing Lustre record (assuming the Lustre
* already exists, at which point we won't need to instrument * data remains immutable as it is now).
* more data, since the Lustre record data is immutable. records
* could just be appended to the array if there is no need to
* search for a specific record.
*/ */
struct lustre_record_ref
{
struct darshan_lustre_record *record;
UT_hash_handle hlink;
};
struct lustre_runtime struct lustre_runtime
{ {
struct lustre_record_ref *ref_array;
struct darshan_lustre_record *record_array; struct darshan_lustre_record *record_array;
int record_array_size; int record_array_size;
int record_array_ndx; int record_array_ndx;
struct lustre_record_ref *record_hash;
}; };
static struct lustre_runtime *lustre_runtime = NULL; static struct lustre_runtime *lustre_runtime = NULL;
...@@ -69,15 +58,16 @@ static void lustre_shutdown(void); ...@@ -69,15 +58,16 @@ static void lustre_shutdown(void);
void darshan_instrument_lustre_file(char *filepath) void darshan_instrument_lustre_file(char *filepath)
{ {
struct lustre_record_ref *lustre_ref; struct darshan_lustre_record *rec;
darshan_record_id rec_id; darshan_record_id rec_id;
int limit_flag;
LUSTRE_LOCK(); LUSTRE_LOCK();
/* make sure the lustre module is already initialized */ /* make sure the lustre module is already initialized */
lustre_runtime_initialize(); lustre_runtime_initialize();
limit_flag = (lustre_runtime->record_array_ndx >= lustre_runtime->record_array_size); /* if the array is full, we just back out */
if(lustre_runtime->record_array_ndx >= lustre_runtime->record_array_size)
return;
/* register a Lustre file record with Darshan */ /* register a Lustre file record with Darshan */
darshan_core_register_record( darshan_core_register_record(
...@@ -85,7 +75,7 @@ void darshan_instrument_lustre_file(char *filepath) ...@@ -85,7 +75,7 @@ void darshan_instrument_lustre_file(char *filepath)
strlen(filepath), strlen(filepath),
DARSHAN_LUSTRE_MOD, DARSHAN_LUSTRE_MOD,
1, 1,
limit_flag, 0,
&rec_id, &rec_id,
NULL); NULL);
...@@ -93,24 +83,14 @@ void darshan_instrument_lustre_file(char *filepath) ...@@ -93,24 +83,14 @@ void darshan_instrument_lustre_file(char *filepath)
if(rec_id == 0) if(rec_id == 0)
return; return;
HASH_FIND(hlink, lustre_runtime->record_hash, &rec_id, /* allocate a new lustre record and append it to the array */
sizeof(darshan_record_id), lustre_ref); rec = &(lustre_runtime->record_array[lustre_runtime->record_array_ndx++]);
if(!lustre_ref) rec->rec_id = rec_id;
{ rec->rank = my_rank;
/* no existing record, allocate a new one and add it to the hash */
lustre_ref = &(lustre_runtime->ref_array[lustre_runtime->record_array_ndx]); /* TODO: gather lustre data, store in record hash */
lustre_ref->record = &(lustre_runtime->record_array[lustre_runtime->record_array_ndx]); /* counters in lustre_ref->record->counters */
lustre_ref->record->rec_id = rec_id; rec->counters[LUSTRE_TEST_COUNTER] = 88;
lustre_ref->record->rank = my_rank;
/* TODO: gather lustre data, store in record hash */
/* counters in lustre_ref->record->counters */
lustre_ref->record->counters[LUSTRE_TEST_COUNTER] = 88;
HASH_ADD(hlink, lustre_runtime->record_hash, record->rec_id,
sizeof(darshan_record_id), lustre_ref);
lustre_runtime->record_array_ndx++;
}
LUSTRE_UNLOCK(); LUSTRE_UNLOCK();
return; return;
...@@ -152,17 +132,13 @@ static void lustre_runtime_initialize() ...@@ -152,17 +132,13 @@ static void lustre_runtime_initialize()
*/ */
lustre_runtime->record_array_size = mem_limit / sizeof(struct darshan_lustre_record); lustre_runtime->record_array_size = mem_limit / sizeof(struct darshan_lustre_record);
lustre_runtime->ref_array = malloc(lustre_runtime->record_array_size *
sizeof(struct lustre_record_ref));
lustre_runtime->record_array = malloc(lustre_runtime->record_array_size * lustre_runtime->record_array = malloc(lustre_runtime->record_array_size *
sizeof(struct darshan_lustre_record)); sizeof(struct darshan_lustre_record));
if(!lustre_runtime->ref_array || !lustre_runtime->record_array) if(!lustre_runtime->record_array)
{ {
lustre_runtime->record_array_size = 0; lustre_runtime->record_array_size = 0;
return; return;
} }
memset(lustre_runtime->ref_array, 0, lustre_runtime->record_array_size *
sizeof(struct lustre_record_ref));
memset(lustre_runtime->record_array, 0, lustre_runtime->record_array_size * memset(lustre_runtime->record_array, 0, lustre_runtime->record_array_size *
sizeof(struct darshan_lustre_record)); sizeof(struct darshan_lustre_record));
...@@ -211,9 +187,6 @@ static void lustre_shutdown(void) ...@@ -211,9 +187,6 @@ static void lustre_shutdown(void)
assert(lustre_runtime); assert(lustre_runtime);
/* TODO: free data structures */ /* TODO: free data structures */
HASH_CLEAR(hlink, lustre_runtime->record_hash);
free(lustre_runtime->ref_array);
free(lustre_runtime->record_array); free(lustre_runtime->record_array);
free(lustre_runtime); free(lustre_runtime);
lustre_runtime = NULL; lustre_runtime = NULL;
......
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