[Darshan-commits] [Git][darshan/darshan][master] 4 commits: add darshan_core_fprintf routine

Philip Carns xgitlab at cels.anl.gov
Thu Nov 29 11:50:23 CST 2018


Philip Carns pushed to branch master at darshan / darshan


Commits:
67efd831 by Shane Snyder at 2018-11-29T16:39:37Z
add darshan_core_fprintf routine

- - - - -
500db6a0 by Shane Snyder at 2018-11-29T16:39:49Z
convert all darshan fprintf calls to internal call

- - - - -
9c83fab7 by Shane Snyder at 2018-11-29T16:45:57Z
Merge branch 'master' into darshan_core_fprintf

- - - - -
a658ce00 by Philip Carns at 2018-11-29T17:50:20Z
Merge branch 'darshan_core_fprintf' into 'master'

implement internal darshan-core fprintf routine

Closes #251

See merge request darshan/darshan!29
- - - - -


5 changed files:

- darshan-runtime/darshan.h
- darshan-runtime/lib/darshan-core.c
- darshan-runtime/lib/darshan-hdf5.c
- darshan-runtime/lib/darshan-lustre.c
- darshan-runtime/lib/darshan-stdio.c


Changes:

=====================================
darshan-runtime/darshan.h
=====================================
@@ -47,7 +47,7 @@
     { \
         __real_ ## __func = dlsym(RTLD_NEXT, #__func); \
         if(!(__real_ ## __func)) { \
-            fprintf(stderr, "Darshan failed to map symbol: %s\n", #__func); \
+            darshan_core_fprintf(stderr, "Darshan failed to map symbol: %s\n", #__func); \
             exit(1); \
        } \
     }
@@ -185,6 +185,15 @@ void *darshan_core_register_record(
  */
 double darshan_core_wtime(void);
 
+/* darshan_core_fprintf()
+ *
+ * Prints internal Darshan output on a given stream.
+ */
+void darshan_core_fprintf(
+    FILE *stream,
+    const char *format,
+    ...);
+
 /* darshan_core_excluded_path()
  *
  * Returns true (1) if the given file path 'path' is in Darshan's


=====================================
darshan-runtime/lib/darshan-core.c
=====================================
@@ -330,8 +330,8 @@ void darshan_core_initialize(int argc, char **argv)
             MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
         if(my_rank == 0)
         {
-            fprintf(stderr, "#darshan:<op>\t<nprocs>\t<time>\n");
-            fprintf(stderr, "darshan:init\t%d\t%f\n", nprocs, init_max);
+            darshan_core_fprintf(stderr, "#darshan:<op>\t<nprocs>\t<time>\n");
+            darshan_core_fprintf(stderr, "darshan:init\t%d\t%f\n", nprocs, init_max);
         }
     }
 
@@ -439,7 +439,7 @@ void darshan_core_shutdown()
     if(strlen(logfile_name) == 0)
     {
         /* failed to generate log file name */
-        fprintf(stderr, "darshan library warning: unable to determine log file path\n");
+        darshan_core_fprintf(stderr, "darshan library warning: unable to determine log file path\n");
         free(logfile_name);
         darshan_core_cleanup(final_core);
         return;
@@ -476,7 +476,7 @@ void darshan_core_shutdown()
     {
         if(my_rank == 0)
         {
-            fprintf(stderr, "darshan library warning: unable to create log file %s\n",
+            darshan_core_fprintf(stderr, "darshan library warning: unable to create log file %s\n",
                 logfile_name);
         }
         free(logfile_name);
@@ -498,7 +498,7 @@ void darshan_core_shutdown()
             final_core->comp_buf, &comp_buf_sz);
         if(all_ret)
         {
-            fprintf(stderr, "darshan library warning: unable to compress job data\n");
+            darshan_core_fprintf(stderr, "darshan library warning: unable to compress job data\n");
             unlink(logfile_name);
         }
         else
@@ -509,7 +509,7 @@ void darshan_core_shutdown()
                 final_core->comp_buf, comp_buf_sz, MPI_BYTE, &status);
             if(all_ret != MPI_SUCCESS)
             {
-                fprintf(stderr,
+                darshan_core_fprintf(stderr,
                         "darshan library warning: unable to write job data to log file %s\n",
                         logfile_name);
                 unlink(logfile_name);
@@ -544,7 +544,7 @@ void darshan_core_shutdown()
     {
         if(my_rank == 0)
         {
-            fprintf(stderr,
+            darshan_core_fprintf(stderr,
                 "darshan library warning: unable to write record hash to log file %s\n",
                 logfile_name);
             unlink(logfile_name);
@@ -632,7 +632,7 @@ void darshan_core_shutdown()
         {
             if(my_rank == 0)
             {
-                fprintf(stderr,
+                darshan_core_fprintf(stderr,
                     "darshan library warning: unable to write %s module data to log file %s\n",
                     darshan_module_names[i], logfile_name);
                 unlink(logfile_name);
@@ -670,7 +670,7 @@ void darshan_core_shutdown()
             sizeof(struct darshan_header), MPI_BYTE, &status);
         if(all_ret != MPI_SUCCESS)
         {
-            fprintf(stderr, "darshan library warning: unable to write header to log file %s\n",
+            darshan_core_fprintf(stderr, "darshan library warning: unable to write header to log file %s\n",
                     logfile_name);
             unlink(logfile_name);
         }
@@ -776,18 +776,18 @@ void darshan_core_shutdown()
 
         if(my_rank == 0)
         {
-            fprintf(stderr, "#darshan:<op>\t<nprocs>\t<time>\n");
-            fprintf(stderr, "darshan:log_open\t%d\t%f\n", nprocs, open_slowest);
-            fprintf(stderr, "darshan:job_write\t%d\t%f\n", nprocs, job_slowest);
-            fprintf(stderr, "darshan:hash_write\t%d\t%f\n", nprocs, rec_slowest);
-            fprintf(stderr, "darshan:header_write\t%d\t%f\n", nprocs, header_slowest);
+            darshan_core_fprintf(stderr, "#darshan:<op>\t<nprocs>\t<time>\n");
+            darshan_core_fprintf(stderr, "darshan:log_open\t%d\t%f\n", nprocs, open_slowest);
+            darshan_core_fprintf(stderr, "darshan:job_write\t%d\t%f\n", nprocs, job_slowest);
+            darshan_core_fprintf(stderr, "darshan:hash_write\t%d\t%f\n", nprocs, rec_slowest);
+            darshan_core_fprintf(stderr, "darshan:header_write\t%d\t%f\n", nprocs, header_slowest);
             for(i = 0; i < DARSHAN_MAX_MODS; i++)
             {
                 if(global_mod_use_count[i])
-                    fprintf(stderr, "darshan:%s_shutdown\t%d\t%f\n", darshan_module_names[i],
+                    darshan_core_fprintf(stderr, "darshan:%s_shutdown\t%d\t%f\n", darshan_module_names[i],
                         nprocs, mod_slowest[i]);
             }
-            fprintf(stderr, "darshan:core_shutdown\t%d\t%f\n", nprocs, all_slowest);
+            darshan_core_fprintf(stderr, "darshan:core_shutdown\t%d\t%f\n", nprocs, all_slowest);
         }
     }
 
@@ -851,7 +851,7 @@ static void *darshan_init_mmap_log(struct darshan_core_runtime* core, int jobid)
     mmap_fd = open(core->mmap_log_name, O_CREAT|O_RDWR|O_EXCL , 0644);
     if(mmap_fd < 0)
     {
-        fprintf(stderr, "darshan library warning: "
+        darshan_core_fprintf(stderr, "darshan library warning: "
             "unable to create darshan log file %s\n", core->mmap_log_name);
         return(NULL);
     }
@@ -861,7 +861,7 @@ static void *darshan_init_mmap_log(struct darshan_core_runtime* core, int jobid)
     ret = ftruncate(mmap_fd, mmap_size);
     if(ret < 0)
     {
-        fprintf(stderr, "darshan library warning: "
+        darshan_core_fprintf(stderr, "darshan library warning: "
             "unable to allocate darshan log file %s\n", core->mmap_log_name);
         close(mmap_fd);
         unlink(core->mmap_log_name);
@@ -874,7 +874,7 @@ static void *darshan_init_mmap_log(struct darshan_core_runtime* core, int jobid)
     mmap_p = mmap(NULL, mmap_size, PROT_WRITE, MAP_SHARED, mmap_fd, 0);
     if(mmap_p == MAP_FAILED)
     {
-        fprintf(stderr, "darshan library warning: "
+        darshan_core_fprintf(stderr, "darshan library warning: "
             "unable to mmap darshan log file %s\n", core->mmap_log_name);
         close(mmap_fd);
         unlink(core->mmap_log_name);
@@ -1078,13 +1078,13 @@ static void darshan_get_exe_and_mounts(struct darshan_core_runtime *core,
         if(strncmp(env_exclusions,"none",strlen(env_exclusions))>=0)
         {
             if (my_rank == 0) 
-                fprintf(stderr, "Darshan info: no system dirs will be excluded\n");
+                darshan_core_fprintf(stderr, "Darshan info: no system dirs will be excluded\n");
             darshan_path_exclusions[0]=NULL;
         }
         else
         {
             if (my_rank == 0) 
-                fprintf(stderr, "Darshan info: the following system dirs will be excluded: %s\n",
+                darshan_core_fprintf(stderr, "Darshan info: the following system dirs will be excluded: %s\n",
                     env_exclusions);
             string = strdup(env_exclusions);
             i = 0;
@@ -1329,7 +1329,7 @@ static void darshan_get_logfile_name(char* logfile_name, int jobid, struct tm* s
     {
         if(strlen(user_logfile_name) >= (PATH_MAX-1))
         {
-            fprintf(stderr, "darshan library warning: user log file name too long.\n");
+            darshan_core_fprintf(stderr, "darshan library warning: user log file name too long.\n");
             logfile_name[0] = '\0';
         }
         else
@@ -2133,6 +2133,25 @@ double darshan_core_wtime()
     return(PMPI_Wtime() - darshan_core->wtime_offset);
 }
 
+#ifdef DARSHAN_PRELOAD
+extern int (*__real_vfprintf)(FILE *stream, const char *format, va_list);
+#else
+extern int __real_vfprintf(FILE *stream, const char *format, va_list);
+#endif
+void darshan_core_fprintf(
+    FILE *stream, const char *format, ...)
+{
+    va_list ap;
+
+    MAP_OR_FAIL(vfprintf);
+
+    va_start(ap, format);
+    __real_vfprintf(stream, format, ap);
+    va_end(ap);
+
+    return;
+}
+
 int darshan_core_excluded_path(const char *path)
 {
     char *exclude, *include;


=====================================
darshan-runtime/lib/darshan-hdf5.c
=====================================
@@ -137,7 +137,7 @@ hid_t DARSHAN_DECL(H5Fcreate)(const char *filename, unsigned flags,
             MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
         if(my_rank == 0)
         {
-            fprintf(stderr, "Darshan HDF5 module error: runtime library version does not match Darshan module.\n");
+            darshan_core_fprintf(stderr, "Darshan HDF5 module error: runtime library version does not match Darshan module.\n");
         }
         return(-1);
     }
@@ -185,7 +185,7 @@ hid_t DARSHAN_DECL(H5Fopen)(const char *filename, unsigned flags,
             MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
         if(my_rank == 0)
         {
-            fprintf(stderr, "Darshan HDF5 module error: runtime library version does not match Darshan module.\n");
+            darshan_core_fprintf(stderr, "Darshan HDF5 module error: runtime library version does not match Darshan module.\n");
         }
         return(-1);
     }


=====================================
darshan-runtime/lib/darshan-lustre.c
=====================================
@@ -251,7 +251,7 @@ static void lustre_shutdown(
             if(rec_ref)
                 rec_ref->record->base_rec.rank = -1;
             else
-                fprintf(stderr, "WARNING: unexpected condition in Darshan, possibly triggered by memory corruption.  Darshan log may be incorrect.\n");
+                darshan_core_fprintf(stderr, "WARNING: unexpected condition in Darshan, possibly triggered by memory corruption.  Darshan log may be incorrect.\n");
         }
 
         /* sort the array of files descending by rank so that we get all of the 


=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
@@ -534,7 +534,6 @@ int DARSHAN_DECL(printf)(const char *format, ...)
     return(ret);
 }
 
-
 int DARSHAN_DECL(fprintf)(FILE *stream, const char *format, ...)
 {
     int ret;



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/f119346b2e441459c026c0f5ef6f2b5c2a56c942...a658ce005608c573bab26ff73078c4c03cb5e05e

-- 
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/f119346b2e441459c026c0f5ef6f2b5c2a56c942...a658ce005608c573bab26ff73078c4c03cb5e05e
You're receiving this email because of your account on xgitlab.cels.anl.gov.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20181129/fbd6ebaa/attachment-0001.html>


More information about the Darshan-commits mailing list