Commit af20f42a authored by Shane Snyder's avatar Shane Snyder

Clean up variable names and source files

parent 601e5ef7
......@@ -19,16 +19,16 @@
#endif
/* update this on file format changes */
#define CP_VERSION "3.00"
#define DARSHAN_LOG_VERSION "3.00"
/* magic number for validating output files and checking byte order */
#define CP_MAGIC_NR 6567223
#define DARSHAN_MAGIC_NR 6567223
/* size (in bytes) of job record */
#define CP_JOB_RECORD_SIZE 4096
#define DARSHAN_JOB_RECORD_SIZE 4096
/* max length of exe string within job record (not counting '\0') */
#define CP_EXE_LEN (CP_JOB_RECORD_SIZE - sizeof(struct darshan_job) - 1)
#define DARSHAN_EXE_LEN (DARSHAN_JOB_RECORD_SIZE - sizeof(struct darshan_job) - 1)
typedef uint64_t darshan_record_id;
......
......@@ -25,7 +25,7 @@ struct darshan_core_module
struct darshan_core_runtime
{
struct darshan_job log_job;
char exe[CP_EXE_LEN+1];
char exe[DARSHAN_EXE_LEN+1];
struct darshan_core_record_ref *rec_hash;
struct darshan_core_module* mod_array[DARSHAN_MAX_MODS];
double wtime_offset;
......
......@@ -158,11 +158,11 @@ static void darshan_core_initialize(int *argc, char ***argv)
/* record exe and arguments */
for(i=0; i<(*argc); i++)
{
chars_left = CP_EXE_LEN-strlen(darshan_core->exe);
chars_left = DARSHAN_EXE_LEN-strlen(darshan_core->exe);
strncat(darshan_core->exe, (*argv)[i], chars_left);
if(i < ((*argc)-1))
{
chars_left = CP_EXE_LEN-strlen(darshan_core->exe);
chars_left = DARSHAN_EXE_LEN-strlen(darshan_core->exe);
strncat(darshan_core->exe, " ", chars_left);
}
}
......@@ -172,16 +172,16 @@ static void darshan_core_initialize(int *argc, char ***argv)
*/
if(argc == 0)
{
chars_left = CP_EXE_LEN-strlen(darshan_core->exe);
chars_left = DARSHAN_EXE_LEN-strlen(darshan_core->exe);
strncat(darshan_core->exe, __progname, chars_left);
chars_left = CP_EXE_LEN-strlen(darshan_core->exe);
chars_left = DARSHAN_EXE_LEN-strlen(darshan_core->exe);
strncat(darshan_core->exe, " <unknown args>", chars_left);
}
if(chars_left == 0)
{
/* we ran out of room; mark that string was truncated */
truncate_offset = CP_EXE_LEN - strlen(truncate_string);
truncate_offset = DARSHAN_EXE_LEN - strlen(truncate_string);
sprintf(&darshan_core->exe[truncate_offset], "%s",
truncate_string);
}
......@@ -354,18 +354,18 @@ static void darshan_core_shutdown()
/* rank 0 is responsible for writing the darshan job information */
if(my_rank == 0)
{
unsigned char tmp_buf[CP_JOB_RECORD_SIZE];
unsigned char tmp_buf[DARSHAN_JOB_RECORD_SIZE];
unsigned char *tmp_ptr;
/* pack the job info and exe/mount info into a buffer for writing */
tmp_ptr = tmp_buf;
memcpy(tmp_ptr, &final_core->log_job, sizeof(struct darshan_job));
tmp_ptr += sizeof(struct darshan_job);
memcpy(tmp_ptr, final_core->trailing_data, CP_EXE_LEN+1);
memcpy(tmp_ptr, final_core->trailing_data, DARSHAN_EXE_LEN+1);
/* write the job information, making sure to prealloc space for the log header */
all_ret = DARSHAN_MPI_CALL(PMPI_File_write_at)(log_fh, sizeof(struct darshan_header),
tmp_buf, CP_JOB_RECORD_SIZE, MPI_BYTE, &status);
tmp_buf, DARSHAN_JOB_RECORD_SIZE, MPI_BYTE, &status);
if(all_ret != MPI_SUCCESS)
{
fprintf(stderr, "darshan library warning: unable to write job data to log file %s\n",
......@@ -374,7 +374,7 @@ static void darshan_core_shutdown()
}
/* TODO: after compression is added, this should be fixed */
log_header.rec_map.off = sizeof(struct darshan_header) + CP_JOB_RECORD_SIZE;
log_header.rec_map.off = sizeof(struct darshan_header) + DARSHAN_JOB_RECORD_SIZE;
}
/* error out if unable to write job information */
......@@ -487,8 +487,8 @@ static void darshan_core_shutdown()
if(my_rank == 0)
{
/* initialize the remaining header fields */
strcpy(log_header.version_string, CP_VERSION);
log_header.magic_nr = CP_MAGIC_NR;
strcpy(log_header.version_string, DARSHAN_LOG_VERSION);
log_header.magic_nr = DARSHAN_MAGIC_NR;
log_header.comp_type = DARSHAN_GZ_COMP;
all_ret = DARSHAN_MPI_CALL(PMPI_File_write_at)(log_fh, 0, &log_header,
......@@ -839,7 +839,7 @@ static void darshan_get_exe_and_mounts_root(struct darshan_core_runtime *core,
/* length of exe has already been safety checked in darshan-posix.c */
strcat(trailing_data, core->exe);
space_left = CP_EXE_LEN - strlen(trailing_data);
space_left = DARSHAN_EXE_LEN - strlen(trailing_data);
/* we make two passes through mounted file systems; in the first pass we
* grab any non-nfs mount points, then on the second pass we grab nfs
......@@ -903,7 +903,7 @@ static char* darshan_get_exe_and_mounts(struct darshan_core_runtime *core)
char* trailing_data;
int space_left;
space_left = CP_EXE_LEN + 1;
space_left = DARSHAN_EXE_LEN + 1;
trailing_data = malloc(space_left);
if(!trailing_data)
{
......
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/* This file contains stubs for the H5F functions intercepted by Darshan.
* They are defined as weak symbols in order to satisfy dependencies of the
* hdf5 wrappers in cases where hdf5 is not being used.
*/
#include "darshan-runtime-config.h"
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include "mpi.h"
#include "darshan.h"
/* hope this doesn't change any time soon */
typedef int hid_t;
typedef int herr_t;
hid_t H5Fcreate(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist) __attribute__((weak));
hid_t H5Fcreate(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan H5Fcreate() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
hid_t H5Fopen(const char *filename, unsigned flags,
hid_t access_plist) __attribute__((weak));
hid_t H5Fopen(const char *filename, unsigned flags,
hid_t access_plist)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan H5Fopen() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
herr_t H5Fclose(hid_t file_id) __attribute__((weak));
herr_t H5Fclose(hid_t file_id)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan H5Fclose() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "darshan-runtime-config.h"
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include "mpi.h"
#include "darshan.h"
/* hope this doesn't change any time soon */
typedef int hid_t;
typedef int herr_t;
#ifdef DARSHAN_PRELOAD
#define __USE_GNU
#include <dlfcn.h>
#include <stdlib.h>
#define DARSHAN_FORWARD_DECL(name,ret,args) \
ret (*__real_ ## name)args = NULL;
#define DARSHAN_DECL(__name) __name
#define MAP_OR_FAIL(func) \
if (!(__real_ ## func)) \
{ \
__real_ ## func = dlsym(RTLD_NEXT, #func); \
if(!(__real_ ## func)) { \
fprintf(stderr, "Darshan failed to map symbol: %s\n", #func); \
exit(1); \
} \
}
#else
#define DARSHAN_FORWARD_DECL(name,ret,args) \
extern ret __real_ ## name args;
#define DARSHAN_DECL(__name) __wrap_ ## __name
#define MAP_OR_FAIL(func)
#endif
DARSHAN_FORWARD_DECL(H5Fcreate, hid_t, (const char *filename, unsigned flags, hid_t create_plist, hid_t access_plist));
DARSHAN_FORWARD_DECL(H5Fopen, hid_t, (const char *filename, unsigned flags, hid_t access_plist));
DARSHAN_FORWARD_DECL(H5Fclose, herr_t, (hid_t file_id));
static struct darshan_file_runtime* darshan_file_by_hid(int hid);
static void darshan_file_close_hid(int hid);
static struct darshan_file_runtime* darshan_file_by_name_sethid(const char* name, int hid);
hid_t DARSHAN_DECL(H5Fcreate)(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist)
{
int ret;
struct darshan_file_runtime* file;
char* tmp;
double tm1;
MAP_OR_FAIL(H5Fcreate);
tm1 = darshan_wtime();
ret = __real_H5Fcreate(filename, flags, create_plist, access_plist);
if(ret >= 0)
{
CP_LOCK();
/* use ROMIO approach to strip prefix if present */
/* strip off prefix if there is one, but only skip prefixes
* if they are greater than length one to allow for windows
* drive specifications (e.g. c:\...)
*/
tmp = strchr(filename, ':');
if (tmp > filename + 1) {
filename = tmp + 1;
}
file = darshan_file_by_name_sethid(filename, ret);
if(file)
{
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
tm1);
CP_INC(file, CP_HDF5_OPENS, 1);
}
CP_UNLOCK();
}
return(ret);
}
hid_t DARSHAN_DECL(H5Fopen)(const char *filename, unsigned flags,
hid_t access_plist)
{
int ret;
struct darshan_file_runtime* file;
char* tmp;
double tm1;
MAP_OR_FAIL(H5Fopen);
tm1 = darshan_wtime();
ret = __real_H5Fopen(filename, flags, access_plist);
if(ret >= 0)
{
CP_LOCK();
/* use ROMIO approach to strip prefix if present */
/* strip off prefix if there is one, but only skip prefixes
* if they are greater than length one to allow for windows
* drive specifications (e.g. c:\...)
*/
tmp = strchr(filename, ':');
if (tmp > filename + 1) {
filename = tmp + 1;
}
file = darshan_file_by_name_sethid(filename, ret);
if(file)
{
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
tm1);
CP_INC(file, CP_HDF5_OPENS, 1);
}
CP_UNLOCK();
}
return(ret);
}
herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
{
struct darshan_file_runtime* file;
int ret;
MAP_OR_FAIL(H5Fclose);
ret = __real_H5Fclose(file_id);
CP_LOCK();
file = darshan_file_by_hid(file_id);
if(file)
{
CP_F_SET(file, CP_F_CLOSE_TIMESTAMP, PMPI_Wtime());
darshan_file_close_hid(file_id);
}
CP_UNLOCK();
return(ret);
}
static struct darshan_file_runtime* darshan_file_by_name_sethid(const char* name, int hid)
{
struct darshan_file_runtime* tmp_file;
tmp_file = darshan_file_by_name_sethandle(name, &hid, sizeof(hid), DARSHAN_HID);
return(tmp_file);
}
static void darshan_file_close_hid(int hid)
{
darshan_file_closehandle(&hid, sizeof(hid), DARSHAN_HID);
return;
}
static struct darshan_file_runtime* darshan_file_by_hid(int hid)
{
struct darshan_file_runtime* tmp_file;
tmp_file = darshan_file_by_handle(&hid, sizeof(hid), DARSHAN_HID);
return(tmp_file);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
This diff is collapsed.
This diff is collapsed.
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/* This file contains stubs for the ncmpi functions intercepted by Darshan.
* They are defined as weak symbols in order to satisfy dependencies of the
* pnetcdf wrappers in cases where pnetcdf is not being used.
*/
#include "darshan-runtime-config.h"
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include "mpi.h"
#include "darshan.h"
int ncmpi_create(MPI_Comm comm, const char *path,
int cmode, MPI_Info info, int *ncidp) __attribute__((weak));
int ncmpi_create(MPI_Comm comm, const char *path,
int cmode, MPI_Info info, int *ncidp)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan ncmpi_create() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
int ncmpi_open(MPI_Comm comm, const char *path,
int omode, MPI_Info info, int *ncidp) __attribute__((weak));
int ncmpi_open(MPI_Comm comm, const char *path,
int omode, MPI_Info info, int *ncidp)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan ncmpi_open() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
int ncmpi_close(int ncid) __attribute__((weak));
int ncmpi_close(int ncid)
{
int rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if(rank == 0)
{
fprintf(stderr, "WARNING: Darshan ncmpi_close() stub called; this is probably the result of a link-time problem.\n");
}
return(-1);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include "darshan-runtime-config.h"
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include "mpi.h"
#include "darshan.h"
#ifdef DARSHAN_PRELOAD
#define __USE_GNU
#include <dlfcn.h>
#include <stdlib.h>
#define DARSHAN_FORWARD_DECL(name,ret,args) \
ret (*__real_ ## name)args = NULL;
#define DARSHAN_DECL(__name) __name
#define MAP_OR_FAIL(func) \
if (!(__real_ ## func)) \
{ \
__real_ ## func = dlsym(RTLD_NEXT, #func); \
if(!(__real_ ## func)) { \
fprintf(stderr, "Darshan failed to map symbol: %s\n", #func); \
exit(1); \
} \
}
#else
#define DARSHAN_FORWARD_DECL(name,ret,args) \
extern ret __real_ ## name args;
#define DARSHAN_DECL(__name) __wrap_ ## __name
#define MAP_OR_FAIL(func)
#endif
DARSHAN_FORWARD_DECL(ncmpi_create, int, (MPI_Comm comm, const char *path, int cmode, MPI_Info info, int *ncidp));
DARSHAN_FORWARD_DECL(ncmpi_open, int, (MPI_Comm comm, const char *path, int omode, MPI_Info info, int *ncidp));
DARSHAN_FORWARD_DECL(ncmpi_close, int, (int ncid));
static struct darshan_file_runtime* darshan_file_by_ncid(int ncid);
static void darshan_file_close_ncid(int ncid);
static struct darshan_file_runtime* darshan_file_by_name_setncid(const char* name, int ncid);
int DARSHAN_DECL(ncmpi_create)(MPI_Comm comm, const char *path,
int cmode, MPI_Info info, int *ncidp)
{
int ret;
struct darshan_file_runtime* file;
char* tmp;
int comm_size;
double tm1;
MAP_OR_FAIL(ncmpi_create);
tm1 = darshan_wtime();
ret = __real_ncmpi_create(comm, path, cmode, info, ncidp);
if(ret == 0)
{
CP_LOCK();
/* use ROMIO approach to strip prefix if present */
/* strip off prefix if there is one, but only skip prefixes
* if they are greater than length one to allow for windows
* drive specifications (e.g. c:\...)
*/
tmp = strchr(path, ':');
if (tmp > path + 1) {
path = tmp + 1;
}
file = darshan_file_by_name_setncid(path, (*ncidp));
if(file)
{
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
tm1);
PMPI_Comm_size(comm, &comm_size);
if(comm_size == 1)
{
CP_INC(file, CP_INDEP_NC_OPENS, 1);
}
else
{
CP_INC(file, CP_COLL_NC_OPENS, 1);
}
}
CP_UNLOCK();
}
return(ret);
}
int DARSHAN_DECL(ncmpi_open)(MPI_Comm comm, const char *path,
int omode, MPI_Info info, int *ncidp)
{
int ret;
struct darshan_file_runtime* file;
char* tmp;
int comm_size;
double tm1;
MAP_OR_FAIL(ncmpi_open);
tm1 = darshan_wtime();
ret = __real_ncmpi_open(comm, path, omode, info, ncidp);
if(ret == 0)
{
CP_LOCK();
/* use ROMIO approach to strip prefix if present */
/* strip off prefix if there is one, but only skip prefixes
* if they are greater than length one to allow for windows
* drive specifications (e.g. c:\...)
*/
tmp = strchr(path, ':');
if (tmp > path + 1) {
path = tmp + 1;
}
file = darshan_file_by_name_setncid(path, (*ncidp));
if(file)
{
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
tm1);
PMPI_Comm_size(comm, &comm_size);
if(comm_size == 1)
{
CP_INC(file, CP_INDEP_NC_OPENS, 1);
}
else
{
CP_INC(file, CP_COLL_NC_OPENS, 1);
}
}
CP_UNLOCK();
}
return(ret);
}
int DARSHAN_DECL(ncmpi_close)(int ncid)
{
struct darshan_file_runtime* file;
int ret;
MAP_OR_FAIL(ncmpi_close);
ret = __real_ncmpi_close(ncid);
CP_LOCK();
file = darshan_file_by_ncid(ncid);
if(file)
{
CP_F_SET(file, CP_F_CLOSE_TIMESTAMP, PMPI_Wtime());
darshan_file_close_ncid(ncid);
}
CP_UNLOCK();
return(ret);
}
static struct darshan_file_runtime* darshan_file_by_name_setncid(const char* name, int ncid)
{
struct darshan_file_runtime* tmp_file;
tmp_file = darshan_file_by_name_sethandle(name, &ncid, sizeof(ncid), DARSHAN_NCID);
return(tmp_file);
}
static void darshan_file_close_ncid(int ncid)
{
darshan_file_closehandle(&ncid, sizeof(ncid), DARSHAN_NCID);
return;
}
static struct darshan_file_runtime* darshan_file_by_ncid(int ncid)
{
struct darshan_file_runtime* tmp_file;
tmp_file = darshan_file_by_handle(&ncid, sizeof(ncid), DARSHAN_NCID);
return(tmp_file);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
......@@ -103,7 +103,7 @@ int darshan_log_getheader(darshan_fd fd, struct darshan_header *header)
/* save the version string */
strncpy(fd->version, header->version_string, 8);
if(header->magic_nr == CP_MAGIC_NR)
if(header->magic_nr == DARSHAN_MAGIC_NR)
{
/* no byte swapping needed, this file is in host format already */
fd->swap_flag = 0;
......@@ -112,7 +112,7 @@ int darshan_log_getheader(darshan_fd fd, struct darshan_header *header)
{
/* try byte swapping */
DARSHAN_BSWAP64(&header->magic_nr);
if(header->magic_nr == CP_MAGIC_NR)
if(header->magic_nr == DARSHAN_MAGIC_NR)
{
fd->swap_flag = 1;
......@@ -150,7 +150,7 @@ int darshan_log_getheader(darshan_fd fd, struct darshan_header *header)
*/
int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
{
char job_buf[CP_JOB_RECORD_SIZE] = {0};
char job_buf[DARSHAN_JOB_RECORD_SIZE] = {0};
int ret;
ret = darshan_log_seek(fd, fd->job_map.off);
......@@ -181,49 +181,14 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
}
/* save trailing job data, so exe and mount information can be retrieved later */
fd->exe_mnt_data = malloc(CP_EXE_LEN+1);
fd->exe_mnt_data = malloc(DARSHAN_EXE_LEN+1);
if(!fd->exe_mnt_data)
return(-1);
memcpy(fd->exe_mnt_data, &job_buf[sizeof(*job)], CP_EXE_LEN+1);
memcpy(fd->exe_mnt_data, &job_buf[sizeof(*job)], DARSHAN_EXE_LEN+1);
return(0);
}
#if 0
#ifdef HAVE_STRNDUP
metadata = strndup(job->metadata, sizeof(job->metadata));
#else
metadata = strdup(job->metadata);
#endif
char *kv;
char *key;
char *value;
char *save;
for(kv=strtok_r(metadata, "\n", &save);
kv != NULL;
kv=strtok_r(NULL, "\n", &save))
{
/* NOTE: we intentionally only split on the first = character.
* There may be additional = characters in the value portion
* (for example, when storing mpi-io hints).
*/
strcpy(buffer, kv);