30 #include <sys/types.h> 36 # include <sys/statvfs.h> 37 # elif (defined __APPLE__) 38 # include <sys/param.h> 39 # include <sys/mount.h> 41 # include <sys/statfs.h> 43 # include <sys/time.h> 79 WARN(
"cannot use O_DIRECT");
80 # define O_DIRECT 000000 82 # define O_DIRECT O_DIRECTIO 99 static time_t currentTime;
100 char* currentTimePtr;
102 if ((currentTime = time(
NULL)) == -1)
103 ERR(
"cannot get current time");
105 #if (_POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || _POSIX_SOURCE) 106 static char threadSafeBuff[32];
107 if ((currentTimePtr = ctime_r(¤tTime, threadSafeBuff)) ==
NULL) {
108 ERR(
"cannot read current time");
111 if ((currentTimePtr = ctime(¤tTime)) ==
NULL) {
112 ERR(
"cannot read current time");
116 return (currentTimePtr);
130 for (i = 0; i < ((size /
sizeof(
IOR_size_t)) / 4); i++) {
131 for (j = 0; j < 4; j++) {
142 MPI_Comm shared_comm;
145 MPI_Comm_split_type (comm, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &shared_comm);
146 MPI_Comm_size (shared_comm, &count);
147 MPI_Comm_free (&shared_comm);
168 MPI_Comm_size(comm, & size);
170 if (getenv(
"IOR_FAKE_TASK_PER_NODES")){
171 int tasksPerNode = atoi(getenv(
"IOR_FAKE_TASK_PER_NODES"));
173 MPI_Comm_rank(comm, & rank);
175 printf(
"Fake tasks per node: using %d\n", tasksPerNode);
186 fprintf(
out_logfile,
"V-1: Entering count_tasks_per_node...\n" );
191 FAIL(
"gethostname()");
195 for (i = 0; i < size-1; i++) {
196 MPI_Recv(hostname,
MAX_PATHLEN, MPI_CHAR, MPI_ANY_SOURCE,
197 MPI_ANY_TAG, comm, &status);
198 if (strcmp(hostname, localhost) == 0) {
204 MPI_Send(localhost,
MAX_PATHLEN, MPI_CHAR, 0, 0, comm);
206 MPI_Bcast(&count, 1, MPI_INT, 0, comm);
216 void ExtractHint(
char *settingVal,
char *valueVal,
char *hintString)
218 char *settingPtr, *valuePtr, *tmpPtr1, *tmpPtr2;
220 settingPtr = (
char *)strtok(hintString,
" =");
221 valuePtr = (
char *)strtok(
NULL,
" =\t\r\n");
222 tmpPtr1 = settingPtr;
223 tmpPtr2 = (
char *)strstr(settingPtr,
"IOR_HINT__MPI__");
224 if (tmpPtr1 == tmpPtr2) {
225 settingPtr += strlen(
"IOR_HINT__MPI__");
228 tmpPtr2 = (
char *)strstr(settingPtr,
"IOR_HINT__GPFS__");
229 if (tmpPtr1 == tmpPtr2) {
230 settingPtr += strlen(
"IOR_HINT__GPFS__");
232 "WARNING: Unable to set GPFS hints (not implemented.)\n");
235 strcpy(settingVal, settingPtr);
236 strcpy(valueVal, valuePtr);
242 void SetHints(MPI_Info * mpiHints,
char *hintsFileName)
259 MPI_CHECK(MPI_Info_create(mpiHints),
"cannot create info object");
262 for (i = 0; environ[i] !=
NULL; i++) {
264 if (strncmp(environ[i],
"IOR_HINT", strlen(
"IOR_HINT")) == 0) {
265 strcpy(hintString, environ[i]);
267 MPI_CHECK(MPI_Info_set(*mpiHints, settingVal, valueVal),
268 "cannot set info object");
273 if (hintsFileName !=
NULL && strcmp(hintsFileName,
"") != 0) {
276 fd = fopen(hintsFileName,
"r");
278 WARN(
"cannot open hints file");
283 (hintString,
"IOR_HINT",
284 strlen(
"IOR_HINT")) == 0) {
288 (*mpiHints, settingVal,
290 "cannot set info object");
295 ERR(
"cannot close hints file");
305 char key[MPI_MAX_INFO_VAL];
306 char value[MPI_MAX_INFO_VAL];
309 MPI_CHECK(MPI_Info_get_nkeys(*mpiHints, &nkeys),
310 "cannot get info object keys");
312 for (i = 0; i < nkeys; i++) {
313 MPI_CHECK(MPI_Info_get_nthkey(*mpiHints, i, key),
314 "cannot get info object key");
315 MPI_CHECK(MPI_Info_get(*mpiHints, key, MPI_MAX_INFO_VAL - 1,
317 "cannot get info object value");
331 rc = sscanf(size_str,
"%lld%c", &size, &range);
333 switch ((
int)range) {
347 }
else if (rc == 0) {
360 char *fileSystemUnitStr;
361 long long int totalFileSystemSize;
362 long long int freeFileSystemSize;
363 long long int totalInodes;
364 long long int freeInodes;
365 double totalFileSystemSizeHR;
366 double usedFileSystemPercentage;
367 double usedInodePercentage;
369 struct statvfs statusBuffer;
371 struct statfs statusBuffer;
375 if (statvfs(fileSystem, &statusBuffer) != 0) {
376 ERR(
"unable to statvfs() file system");
379 if (statfs(fileSystem, &statusBuffer) != 0) {
380 ERR(
"unable to statfs() file system");
386 totalFileSystemSize = statusBuffer.f_blocks * statusBuffer.f_frsize;
387 freeFileSystemSize = statusBuffer.f_bfree * statusBuffer.f_frsize;
389 totalFileSystemSize = statusBuffer.f_blocks * statusBuffer.f_bsize;
390 freeFileSystemSize = statusBuffer.f_bfree * statusBuffer.f_bsize;
393 usedFileSystemPercentage = (1 - ((double)freeFileSystemSize
394 / (
double)totalFileSystemSize)) * 100;
395 totalFileSystemSizeHR =
396 (double)totalFileSystemSize / (
double)(1<<30);
397 fileSystemUnitStr =
"GiB";
398 if (totalFileSystemSizeHR > 1024) {
399 totalFileSystemSizeHR = (double)totalFileSystemSize / (
double)((
long long)1<<40);
400 fileSystemUnitStr =
"TiB";
404 totalInodes = statusBuffer.f_files;
405 freeInodes = statusBuffer.f_ffree;
406 usedInodePercentage =
407 (1 - ((double)freeInodes / (
double)totalInodes)) * 100;
410 if (realpath(fileSystem, realPath) ==
NULL) {
411 ERR(
"unable to use realpath()");
417 "FS", totalFileSystemSizeHR, fileSystemUnitStr,
418 usedFileSystemPercentage);
420 (
double)totalInodes / (
double)(1<<20),
421 usedInodePercentage);
425 fprintf(
out_resultfile,
"\"Capacity\": \"%.1f %s\", \"Used Capacity\": \"%2.1f%%\",",
426 totalFileSystemSizeHR, fileSystemUnitStr,
427 usedFileSystemPercentage);
428 fprintf(
out_resultfile,
"\"Inodes\": \"%.1f Mi\", \"Used Inodes\" : \"%2.1f%%\"\n",
429 (
double)totalInodes / (
double)(1<<20),
430 usedInodePercentage);
443 int Regex(
char *
string,
char *pattern)
450 regcomp(®Ex, pattern, REG_EXTENDED);
451 if (regexec(®Ex,
string, 1, ®Match, 0) == 0) {
465 unsigned int randomSeed;
471 struct timeval randGenTimer;
472 gettimeofday(&randGenTimer, (
struct timezone *)
NULL);
473 randomSeed = randGenTimer.tv_usec;
476 MPI_CHECK(MPI_Bcast(&randomSeed, 1, MPI_INT, 0,
477 testComm),
"cannot broadcast random seed value");
485 int uname(
struct utsname *name)
487 DWORD nodeNameSize =
sizeof(name->nodename) - 1;
489 memset(name, 0,
sizeof(
struct utsname));
490 if (!GetComputerNameEx
491 (ComputerNameDnsFullyQualified, name->nodename, &nodeNameSize))
492 ERR(
"GetComputerNameEx failed");
494 strncpy(name->sysname,
"Windows",
sizeof(name->sysname) - 1);
496 strncpy(name->release,
"-",
sizeof(name->release) - 1);
497 strncpy(name->version,
"-",
sizeof(name->version) - 1);
498 strncpy(name->machine,
"-",
sizeof(name->machine) - 1);
515 struct timeval timer;
517 if (gettimeofday(&timer, (
struct timezone *)
NULL) != 0)
518 ERR(
"cannot use gettimeofday()");
519 timeVal = (double)timer.tv_sec + ((
double)timer.tv_usec / 1000000);
521 timeVal = MPI_Wtime();
523 ERR(
"cannot use MPI_Wtime()");
540 double roottimestamp;
544 MPI_CHECK(MPI_Reduce(×tamp, &min, 1, MPI_DOUBLE,
546 "cannot reduce tasks' times");
547 MPI_CHECK(MPI_Reduce(×tamp, &max, 1, MPI_DOUBLE,
549 "cannot reduce tasks' times");
554 "cannot broadcast root's time");
566 static char datestring[80];
567 time_t cur_timestamp;
570 fprintf(
out_logfile,
"V-1: Entering PrintTimestamp...\n" );
574 cur_timestamp = time(
NULL);
575 strftime(datestring, 80,
"%m/%d/%Y %T", localtime(&cur_timestamp));
586 FILE * out = fopen(filename,
"r");
592 int ret = fscanf(out,
"%lld", & data);
606 FILE * out = fopen(filename,
"w");
608 FAIL(
"Cannot write to the stonewalling file!");
610 fprintf(out,
"%lld", (
long long) count);
618 if (
rank == 0 && delay > 0) {
620 fprintf(
out_logfile,
"delaying %d seconds . . .\n", delay);
634 char m_str[8], g_str[8], t_str[8];
640 strcpy(m_str,
"MiB");
641 strcpy(g_str,
"GiB");
642 strcpy(t_str,
"TiB");
654 snprintf(valueStr,
MAX_STR-1,
"%.2f %s",
655 (
double)((
double)value / t), t_str);
657 snprintf(valueStr,
MAX_STR-1,
"%d %s", (
int)(value / t), t_str);
659 }
else if (value >= g) {
661 snprintf(valueStr,
MAX_STR-1,
"%.2f %s",
662 (
double)((
double)value / g), g_str);
664 snprintf(valueStr,
MAX_STR-1,
"%d %s", (
int)(value / g), g_str);
666 }
else if (value >= m) {
668 snprintf(valueStr,
MAX_STR-1,
"%.2f %s",
669 (
double)((
double)value / m), m_str);
671 snprintf(valueStr,
MAX_STR-1,
"%d %s", (
int)(value / m), m_str);
673 }
else if (value >= 0) {
674 snprintf(valueStr,
MAX_STR-1,
"%d bytes", (
int)value);
676 snprintf(valueStr,
MAX_STR-1,
"-");
char * HumanReadable(IOR_offset_t value, int base)
void set_o_direct_flag(int *fd)
void ShowHints(MPI_Info *mpiHints)
int64_t ReadStoneWallingIterations(char *const filename)
int CountTasksPerNode(MPI_Comm comm)
enum OutputFormat_t outputFormat
IOR_offset_t StringToBytes(char *size_str)
static double TimeDeviation(void)
void ShowFileSystemSize(char *fileSystem)
void SeedRandGen(MPI_Comm testComm)
char * CurrentTimeString(void)
#define MPI_CHECK(MPI_STATUS, MSG)
double wall_clock_deviation
double GetTimeStamp(void)
void StoreStoneWallingIterations(char *const filename, int64_t count)
static char hostname[MAX_PATHLEN]
void ExtractHint(char *settingVal, char *valueVal, char *hintString)
void SetHints(MPI_Info *mpiHints, char *hintsFileName)
void DelaySecs(int delay)
int Regex(char *string, char *pattern)
void DumpBuffer(void *buffer, size_t size)
long long int IOR_offset_t