Commit 81c95f7d authored by Ian Lynagh's avatar Ian Lynagh

Use StgWord64 instead of ullong

This patch also fixes ullong_format_string (renamed to showStgWord64)
so that it works with values outside the 32bit range (trac #3979), and
simplifies the without-commas case.
parent 7dbc1d8f
......@@ -16,13 +16,6 @@
typedef unsigned int nat; /* at least 32 bits (like int) */
typedef unsigned long lnat; /* at least 32 bits */
#ifndef _MSC_VER
typedef unsigned long long ullong; /* at least 32 bits */
typedef long long llong;
#else
typedef unsigned __int64 ullong; /* at least 32 bits */
typedef __int64 llong;
#endif
/* ullong (64|128-bit) type: only include if needed (not ANSI) */
#if defined(__GNUC__)
......
......@@ -180,10 +180,10 @@ init_countable_events(void)
static void
papi_report_event(const char *name, ullong value)
papi_report_event(const char *name, StgWord64 value)
{
static char temp[BIG_STRING_LEN];
ullong_format_string(value,temp,rtsTrue/*commas*/);
showStgWord64(value,temp,rtsTrue/*commas*/);
statsPrintf(" %15s %15s\n", name, temp);
}
......
......@@ -40,7 +40,7 @@ unsigned int HP_ID;
/* figures for the profiling report.
*/
static ullong total_alloc;
static StgWord64 total_alloc;
static lnat total_prof_ticks;
/* Globals for opening the profiling log file(s)
......@@ -770,7 +770,7 @@ reportCCSProfiling( void )
(int) RtsFlags.MiscFlags.tickInterval);
fprintf(prof_file, "\ttotal alloc = %11s bytes",
ullong_format_string(total_alloc * sizeof(W_),
showStgWord64(total_alloc * sizeof(W_),
temp, rtsTrue/*commas*/));
#if defined(PROFILING_DETAIL_COUNTS)
......
......@@ -330,25 +330,74 @@ time_str(void)
-------------------------------------------------------------------------- */
char *
ullong_format_string(ullong x, char *s, rtsBool with_commas)
showStgWord64(StgWord64 x, char *s, rtsBool with_commas)
{
if (x < (ullong)1000)
sprintf(s, "%lu", (lnat)x);
else if (x < (ullong)1000000)
sprintf(s, (with_commas) ? "%lu,%3.3lu" : "%lu%3.3lu",
(lnat)((x)/(ullong)1000),
(lnat)((x)%(ullong)1000));
else if (x < (ullong)1000000000)
sprintf(s, (with_commas) ? "%lu,%3.3lu,%3.3lu" : "%lu%3.3lu%3.3lu",
(lnat)((x)/(ullong)1000000),
(lnat)((x)/(ullong)1000%(ullong)1000),
(lnat)((x)%(ullong)1000));
else
sprintf(s, (with_commas) ? "%lu,%3.3lu,%3.3lu,%3.3lu" : "%lu%3.3lu%3.3lu%3.3lu",
(lnat)((x)/(ullong)1000000000),
(lnat)((x)/(ullong)1000000%(ullong)1000),
(lnat)((x)/(ullong)1000%(ullong)1000),
(lnat)((x)%(ullong)1000));
if (with_commas) {
if (x < (StgWord64)1e3)
sprintf(s, "%" FMT_Word64, (StgWord64)x);
else if (x < (StgWord64)1e6)
sprintf(s, "%" FMT_Word64 ",%03" FMT_Word64,
(StgWord64)(x / 1000),
(StgWord64)(x % 1000));
else if (x < (StgWord64)1e9)
sprintf(s, "%" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64,
(StgWord64)(x / 1e6),
(StgWord64)((x / 1000) % 1000),
(StgWord64)(x % 1000));
else if (x < (StgWord64)1e12)
sprintf(s, "%" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64,
(StgWord64)(x / (StgWord64)1e9),
(StgWord64)((x / (StgWord64)1e6) % 1000),
(StgWord64)((x / (StgWord64)1e3) % 1000),
(StgWord64)(x % 1000));
else if (x < (StgWord64)1e15)
sprintf(s, "%" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64,
(StgWord64)(x / (StgWord64)1e12),
(StgWord64)((x / (StgWord64)1e9) % 1000),
(StgWord64)((x / (StgWord64)1e6) % 1000),
(StgWord64)((x / (StgWord64)1e3) % 1000),
(StgWord64)(x % 1000));
else if (x < (StgWord64)1e18)
sprintf(s, "%" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64,
(StgWord64)(x / (StgWord64)1e15),
(StgWord64)((x / (StgWord64)1e12) % 1000),
(StgWord64)((x / (StgWord64)1e9) % 1000),
(StgWord64)((x / (StgWord64)1e6) % 1000),
(StgWord64)((x / (StgWord64)1e3) % 1000),
(StgWord64)(x % 1000));
else
sprintf(s, "%" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64
",%03" FMT_Word64,
(StgWord64)(x / (StgWord64)1e18),
(StgWord64)((x / (StgWord64)1e15) % 1000),
(StgWord64)((x / (StgWord64)1e12) % 1000),
(StgWord64)((x / (StgWord64)1e9) % 1000),
(StgWord64)((x / (StgWord64)1e6) % 1000),
(StgWord64)((x / (StgWord64)1e3) % 1000),
(StgWord64)(x % 1000));
}
else {
sprintf(s, "%" FMT_Word64, x);
}
return s;
}
......
......@@ -35,7 +35,7 @@ void stgFree(void* p);
void heapOverflow(void);
char *time_str(void);
char *ullong_format_string(ullong, char *, rtsBool);
char *showStgWord64(StgWord64, char *, rtsBool);
#ifdef DEBUG
void heapCheckFail( void );
......
......@@ -39,11 +39,11 @@ static Ticks MutElapsedStamp = 0;
static Ticks ExitUserTime = 0;
static Ticks ExitElapsedTime = 0;
static ullong GC_tot_alloc = 0;
static ullong GC_tot_copied = 0;
static StgWord64 GC_tot_alloc = 0;
static StgWord64 GC_tot_copied = 0;
static ullong GC_par_max_copied = 0;
static ullong GC_par_avg_copied = 0;
static StgWord64 GC_par_max_copied = 0;
static StgWord64 GC_par_avg_copied = 0;
static Ticks GC_start_time = 0, GC_tot_time = 0; /* User GC Time */
static Ticks GCe_start_time = 0, GCe_tot_time = 0; /* Elapsed GC time */
......@@ -375,10 +375,10 @@ stat_endGC (lnat alloc, lnat live, lnat copied, lnat gen,
GC_coll_times[gen] += gc_time;
GC_coll_etimes[gen] += gc_etime;
GC_tot_copied += (ullong) copied;
GC_tot_alloc += (ullong) alloc;
GC_par_max_copied += (ullong) max_copied;
GC_par_avg_copied += (ullong) avg_copied;
GC_tot_copied += (StgWord64) copied;
GC_tot_alloc += (StgWord64) alloc;
GC_par_max_copied += (StgWord64) max_copied;
GC_par_avg_copied += (StgWord64) avg_copied;
GC_tot_time += gc_time;
GCe_tot_time += gc_etime;
......@@ -519,7 +519,7 @@ StgInt TOTAL_CALLS=1;
/* Report the value of a counter */
#define REPORT(counter) \
{ \
ullong_format_string(counter,temp,rtsTrue/*commas*/); \
showStgWord64(counter,temp,rtsTrue/*commas*/); \
statsPrintf(" (" #counter ") : %s\n",temp); \
}
......@@ -570,22 +570,22 @@ stat_exit(int alloc)
}
if (RtsFlags.GcFlags.giveStats >= SUMMARY_GC_STATS) {
ullong_format_string(GC_tot_alloc*sizeof(W_),
showStgWord64(GC_tot_alloc*sizeof(W_),
temp, rtsTrue/*commas*/);
statsPrintf("%16s bytes allocated in the heap\n", temp);
ullong_format_string(GC_tot_copied*sizeof(W_),
showStgWord64(GC_tot_copied*sizeof(W_),
temp, rtsTrue/*commas*/);
statsPrintf("%16s bytes copied during GC\n", temp);
if ( ResidencySamples > 0 ) {
ullong_format_string(MaxResidency*sizeof(W_),
showStgWord64(MaxResidency*sizeof(W_),
temp, rtsTrue/*commas*/);
statsPrintf("%16s bytes maximum residency (%ld sample(s))\n",
temp, ResidencySamples);
}
ullong_format_string(MaxSlop*sizeof(W_), temp, rtsTrue/*commas*/);
showStgWord64(MaxSlop*sizeof(W_), temp, rtsTrue/*commas*/);
statsPrintf("%16s bytes maximum slop\n", temp);
statsPrintf("%16ld MB total memory in use (%ld MB lost due to fragmentation)\n\n",
......@@ -670,10 +670,10 @@ stat_exit(int alloc)
TICK_TO_DBL(GCe_tot_time)*100/TICK_TO_DBL(etime));
if (time - GC_tot_time - PROF_VAL(RP_tot_time + HC_tot_time) == 0)
ullong_format_string(0, temp, rtsTrue/*commas*/);
showStgWord64(0, temp, rtsTrue/*commas*/);
else
ullong_format_string(
(ullong)((GC_tot_alloc*sizeof(W_))/
showStgWord64(
(StgWord64)((GC_tot_alloc*sizeof(W_))/
TICK_TO_DBL(time - GC_tot_time -
PROF_VAL(RP_tot_time + HC_tot_time))),
temp, rtsTrue/*commas*/);
......@@ -734,7 +734,7 @@ stat_exit(int alloc)
fmt2 = "%d GCs, %ld/%ld avg/max bytes residency (%ld samples), %luM in use, %.2f INIT (%.2f elapsed), %.2f MUT (%.2f elapsed), %.2f GC (%.2f elapsed) :ghc>>\n";
}
/* print the long long separately to avoid bugginess on mingwin (2001-07-02, mingw-0.5) */
statsPrintf(fmt1, GC_tot_alloc*(ullong)sizeof(W_));
statsPrintf(fmt1, GC_tot_alloc*(StgWord64)sizeof(W_));
statsPrintf(fmt2,
total_collections,
ResidencySamples == 0 ? 0 :
......
......@@ -42,7 +42,7 @@ are also used when simulating parallel execution, i.e. on GranSim.
/* Needed for dumping routines */
#if defined(PAR)
# define TIME ullong
# define TIME StgWord64
# define CURRENT_TIME msTime()
# define TIME_ON_PROC(p) msTime()
# define CURRENT_PROC thisPE
......
......@@ -27,8 +27,8 @@
/* external data */
extern double ElapsedTimeStart;
extern ullong GC_tot_alloc;
extern ullong GC_tot_copied;
extern StgWord64 GC_tot_alloc;
extern StgWord64 GC_tot_copied;
extern lnat MaxResidency; /* in words; for stats only */
extern lnat ResidencySamples; /* for stats only */
......@@ -304,14 +304,14 @@ globalParStat_exit(void)
fprintf(sf, "%11d sparks ignored\n",
globalParStats.tot_sparks_ignored);
*/
ullong_format_string(globalParStats.res_tp, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.res_tp, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s thread pool residency", temp);
fprintf(sf, " (avg: %3.2f; %d times (%2.2f%%) of %d empty)\n",
(double)globalParStats.tot_tp/(double)globalParStats.cnt_tp,
globalParStats.emp_tp,
globalParStats.emp_tp*100.0/(double)globalParStats.cnt_tp,
globalParStats.cnt_tp);
ullong_format_string(globalParStats.res_sp, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.res_sp, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s spark pool residency", temp);
fprintf(sf, " (avg: %3.2f; %d times (%2.2f%%) of %d empty)\n",
......@@ -319,7 +319,7 @@ globalParStat_exit(void)
globalParStats.emp_sp,
globalParStats.emp_sp*100.0/(double)globalParStats.cnt_sp,
globalParStats.cnt_sp);
//ullong_format_string(globalParStats.tot_fishes, temp, rtsTrue/*commas*/);
//showStgWord64(globalParStats.tot_fishes, temp, rtsTrue/*commas*/);
fprintf(sf, "%11d messages sent (%d fish, %d fetch, %d resume, %d schedule",
globalParStats.tot_fish_mess+globalParStats.tot_fetch_mess+
globalParStats.tot_resume_mess+globalParStats.tot_schedule_mess,
......@@ -339,33 +339,33 @@ globalParStat_exit(void)
#endif
fprintf(sf,")\n\n");
ullong_format_string(globalParStats.tot_size_GA*sizeof(W_), temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.tot_size_GA*sizeof(W_), temp, rtsTrue/*commas*/);
fprintf(sf, "%11s bytes of global heap in total ", temp);
fprintf(sf, "(%5.2f%% of total allocated heap)\n",
globalParStats.tot_size_GA*sizeof(W_)*100.0/(double)GC_tot_alloc*sizeof(W_));
ullong_format_string(globalParStats.res_size_GA*sizeof(W_), temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.res_size_GA*sizeof(W_), temp, rtsTrue/*commas*/);
fprintf(sf, "%11s bytes global heap residency ", temp);
fprintf(sf, "(%5.2f%% of max heap residency)\n",
globalParStats.res_size_GA*sizeof(W_)*100.0/(double)MaxResidency*sizeof(W_));
//ullong_format_string(globalParStats.res_mark_GA, temp, rtsTrue/*commas*/);
//showStgWord64(globalParStats.res_mark_GA, temp, rtsTrue/*commas*/);
//fprintf(sf, "%11s GAs residency in GALA table ", temp);
// ullong_format_string(globalParStats.tot_mark_GA, temp, rtsTrue/*commas*/);
// showStgWord64(globalParStats.tot_mark_GA, temp, rtsTrue/*commas*/);
//fprintf(sf, "(avg %5.2f; %d samples)\n",
// (double)globalParStats.tot_mark_GA/(double)globalParStats.cnt_mark_GA,
// globalParStats.cnt_mark_GA);
ullong_format_string(globalParStats.local_alloc_GA, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.local_alloc_GA, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s GAs locally allocated (calls to makeGlobal)\n", temp);
ullong_format_string(globalParStats.tot_rebuild_GA, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.tot_rebuild_GA, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s live GAs in total (after rebuilding tables)\n", temp);
ullong_format_string(globalParStats.res_rebuild_GA, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.res_rebuild_GA, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s GAs residency (after rebuilding tables) ", temp);
fprintf(sf, "(avg %5.2f; %d samples)\n",
(double)globalParStats.tot_rebuild_GA/(double)globalParStats.cnt_rebuild_GA,
globalParStats.cnt_rebuild_GA);
ullong_format_string(globalParStats.res_free_GA, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.res_free_GA, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s residency of freeing GAs", temp);
fprintf(sf, " (avg %5.2f; %d samples)\n",
(double)globalParStats.tot_free_GA/(double)globalParStats.cnt_free_GA,
......@@ -379,9 +379,9 @@ globalParStat_exit(void)
globalParStats.time_rebuild_GA*100./time, time,
globalParStats.time_rebuild_GA*100./etime, etime);
ullong_format_string(globalParStats.tot_sparks_marked, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.tot_sparks_marked, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s sparks marked\t", temp);
ullong_format_string(globalParStats.res_sparks_marked, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.res_sparks_marked, temp, rtsTrue/*commas*/);
fprintf(sf, "%6s spark mark residency\n", temp);
fprintf(sf, "%11.2fs spent marking sparks (%7.2f%% of %7.2fs; %7.2f%% of %7.2fs elapsed)\n",
globalParStats.time_sparks,
......@@ -390,13 +390,13 @@ globalParStat_exit(void)
fprintf(sf,"\n");
ullong_format_string(globalParStats.tot_packets, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.tot_packets, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s packets sent\n", temp);
ullong_format_string(globalParStats.tot_packet_size, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.tot_packet_size, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s bytes of graph sent in total (max %d; avg %.2f)\n",
temp, globalParStats.res_packet_size,
(double)globalParStats.tot_packet_size/(double)globalParStats.tot_packets);
ullong_format_string(globalParStats.tot_thunks, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.tot_thunks, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s thunks sent in total (max %d; avg %.2f)\n",
temp, globalParStats.res_thunks,
(double)globalParStats.tot_thunks/(double)globalParStats.tot_packets);
......@@ -405,13 +405,13 @@ globalParStat_exit(void)
globalParStats.time_pack*100./time, time,
globalParStats.time_pack*100./etime, etime);
ullong_format_string(globalParStats.rec_packets, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.rec_packets, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s packets received\n", temp);
ullong_format_string(globalParStats.rec_packet_size, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.rec_packet_size, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s bytes of graph received in total (max %d; avg %.2f)\n",
temp, globalParStats.rec_res_packet_size,
(double)globalParStats.rec_packet_size/(double)globalParStats.rec_packets);
ullong_format_string(globalParStats.rec_thunks, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.rec_thunks, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s thunks received in total (max %d; avg %.2f)\n",
temp, globalParStats.rec_res_thunks,
(double)globalParStats.rec_thunks/(double)globalParStats.rec_packets);
......@@ -422,9 +422,9 @@ globalParStat_exit(void)
fprintf(sf,"\n");
ullong_format_string(globalParStats.tot_arrs, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.tot_arrs, temp, rtsTrue/*commas*/);
fprintf(sf, "%11s bytearrays sent; ", temp);
ullong_format_string(globalParStats.tot_arr_size, temp, rtsTrue/*commas*/);
showStgWord64(globalParStats.tot_arr_size, temp, rtsTrue/*commas*/);
fprintf(sf, " %s bytes in total (avg %.2f)\n",
temp,
(double)globalParStats.tot_arr_size/(double)globalParStats.tot_arrs);
......
......@@ -38,7 +38,7 @@ GlobalParStats globalParStats;
#endif
#if defined(PAR)
ullong startTime = 0;
StgWord64 startTime = 0;
#endif
#if defined(PAR) && !defined(DEBUG)
......@@ -345,7 +345,7 @@ int prog_argc, rts_argc;
ASSERT(startTime==0);
// startTime = msTime();
startTime = CURRENT_TIME;
ullong_format_string(CURRENT_TIME, time_string, rtsFalse/*no commas!*/);
showStgWord64(CURRENT_TIME, time_string, rtsFalse/*no commas!*/);
fprintf(gr_file, "PE %2u [%s]: TIME\n", thisPE, time_string);
# if 0
......@@ -407,7 +407,7 @@ end_gr_simulation(void)
{
char time_string[TIME_STR_LEN];
ullong_format_string(CURRENT_TIME, time_string, rtsFalse/*no commas!*/);
showStgWord64(CURRENT_TIME, time_string, rtsFalse/*no commas!*/);
if (RtsFlags.GranFlags.GranSimStats.Suppressed)
return;
......@@ -530,7 +530,7 @@ end_gr_simulation(void)
{
char time_string[TIME_STR_LEN];
ullong_format_string(CURRENT_TIME-startTime, time_string, rtsFalse/*no commas!*/);
showStgWord64(CURRENT_TIME-startTime, time_string, rtsFalse/*no commas!*/);
fprintf(stderr, "Computation finished after @ %s @ ms. %d sparks created, %d sparks ignored. Check %s for details.\n",
time_string, sparksCreated, sparksIgnored, gr_filename);
......@@ -590,10 +590,10 @@ StgInt sparkname, len;
StgWord id;
char time_string[TIME_STR_LEN], node_str[NODE_STR_LEN];
# if defined(GRAN)
ullong_format_string(time,
showStgWord64(time,
time_string, rtsFalse/*no commas!*/);
# elif defined(PAR)
ullong_format_string(time,
showStgWord64(time,
time_string, rtsFalse/*no commas!*/);
# endif
output_file = gr_file;
......@@ -702,10 +702,10 @@ rtsBool mandatory_thread;
FILE *output_file; // DEBUGGING ONLY !!!!!!!!!!!!!!!!!!!!!!!!!1
char time_string[TIME_STR_LEN];
# if defined(GRAN)
ullong_format_string(TIME_ON_PROC(proc),
showStgWord64(TIME_ON_PROC(proc),
time_string, rtsFalse/*no commas!*/);
# elif defined(PAR)
ullong_format_string(CURRENT_TIME,
showStgWord64(CURRENT_TIME,
time_string, rtsFalse/*no commas!*/);
# endif
......
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