[mpich2-commits] r6745 - mpich2/trunk/src/util/dbg

goodell at mcs.anl.gov goodell at mcs.anl.gov
Tue May 25 14:53:19 CDT 2010


Author: goodell
Date: 2010-05-25 14:53:19 -0500 (Tue, 25 May 2010)
New Revision: 6745

Modified:
   mpich2/trunk/src/util/dbg/dbg_printf.c
Log:
warning and usability fix for debug logging thread IDs

A larger type avoids a warning and information loss when casting,
and using %llx instead of %d gives a more succinct and easier to read
format.

Reviewed by buntinas at .

Modified: mpich2/trunk/src/util/dbg/dbg_printf.c
===================================================================
--- mpich2/trunk/src/util/dbg/dbg_printf.c	2010-05-25 19:44:05 UTC (rev 6744)
+++ mpich2/trunk/src/util/dbg/dbg_printf.c	2010-05-25 19:53:19 UTC (rev 6745)
@@ -422,7 +422,7 @@
     void *p;
     MPID_Time_t t;
     double  curtime;
-    int threadID  = 0;
+    unsigned long long int threadID  = 0;
     /* Note that pthread_self gives you an id that is the address of the 
        thread's private data, which can be the same for all processes
        in an executable.  Thus, the thread_id will not always serve as the 
@@ -440,7 +440,7 @@
     {
 	MPIU_Thread_id_t tid;
 	MPIU_Thread_self(&tid);
-	threadID = (int)tid;
+	threadID = (unsigned long long int)tid;
     }
 #endif
 #if defined(HAVE_GETPID)
@@ -461,7 +461,7 @@
 	case 0:
 	    va_start(list,fmat);
 	    str = va_arg(list,char *);
-	    fprintf( dbg_fp, "%d\t%d\t%d[%d]\t%d\t%f\t%s\t%d\t%s\n",
+	    fprintf( dbg_fp, "%d\t%d\t%llx[%d]\t%d\t%f\t%s\t%d\t%s\n",
 		     worldNum, worldRank, threadID, pid, class, curtime, 
 		     file, line, str );
 	    break;
@@ -470,7 +470,7 @@
 	    str = va_arg(list,char *);
 	    MPIU_Snprintf( stmp, sizeof(stmp), fmat, str );
 	    va_end(list);
-	    fprintf( dbg_fp, "%d\t%d\t%d[%d]\t%d\t%f\t%s\t%d\t%s\n",
+	    fprintf( dbg_fp, "%d\t%d\t%llx[%d]\t%d\t%f\t%s\t%d\t%s\n",
 		     worldNum, worldRank, threadID, pid, class, curtime, 
 		     file, line, stmp );
 	    break;
@@ -479,7 +479,7 @@
 	    i = va_arg(list,int);
 	    MPIU_Snprintf( stmp, sizeof(stmp), fmat, i);
 	    va_end(list);
-	    fprintf( dbg_fp, "%d\t%d\t%d[%d]\t%d\t%f\t%s\t%d\t%s\n",
+	    fprintf( dbg_fp, "%d\t%d\t%llx[%d]\t%d\t%f\t%s\t%d\t%s\n",
 		     worldNum, worldRank, threadID, pid, class, curtime, 
 		     file, line, stmp );
 	    break;
@@ -488,7 +488,7 @@
 	    p = va_arg(list,void *);
 	    MPIU_Snprintf( stmp, sizeof(stmp), fmat, p);
 	    va_end(list);
-	    fprintf( dbg_fp, "%d\t%d\t%d[%d]\t%d\t%f\t%s\t%d\t%s\n",
+	    fprintf( dbg_fp, "%d\t%d\t%llx[%d]\t%d\t%f\t%s\t%d\t%s\n",
 		     worldNum, worldRank, threadID, pid, class, curtime, 
 		     file, line, stmp );
 	    break;
@@ -940,7 +940,7 @@
     /* FIXME: Need to know how many MPI_COMM_WORLDs are known */
     int nWorld = 1;
 #ifdef MPICH_IS_THREADED
-    int threadID = 0;
+    unsigned long long int threadID = 0;
     int nThread = 2;
 #else
     int nThread = 1;
@@ -1015,13 +1015,13 @@
             }
             else if (*p == 't') {
 #ifdef MPICH_IS_THREADED
-                char threadIDAsChar[20];
+                char threadIDAsChar[30];
                 MPIU_Thread_id_t tid;
                 MPIU_Thread_self(&tid);
-                threadID = (int)tid;
+                threadID = (unsigned long long int)tid;
 
                 MPIU_Snprintf( threadIDAsChar, sizeof(threadIDAsChar), 
-                               "%d", threadID );
+                               "%llx", threadID );
                 *pDest = 0;
                 MPIU_Strnapp( filename, threadIDAsChar, len );
                 pDest += strlen(threadIDAsChar);



More information about the mpich2-commits mailing list