31 #include <sys/types.h> 37 # include <sys/statvfs.h> 38 # elif (defined __APPLE__) 39 # include <sys/param.h> 40 # include <sys/mount.h> 42 # include <sys/statfs.h> 44 # include <sys/time.h> 69 void * d = malloc(size);
71 ERR(
"Could not malloc an array");
80 va_start(args, format);
81 vsnprintf(msg, 4096, format, args);
83 fprintf(
out_logfile,
"%s: Process %d: FAILED in %s, %s: %s\n",
97 rc = sscanf(size_str,
" %d %% ", &percent);
100 if (percent > 100 || percent < 0)
101 ERR(
"percentage must be between 0 and 100");
104 page_size = sysconf(_SC_PAGESIZE);
106 page_size = getpagesize();
109 #ifdef _SC_PHYS_PAGES 110 num_pages = sysconf(_SC_PHYS_PAGES);
112 ERR(
"sysconf(_SC_PHYS_PAGES) is not supported");
114 ERR(
"sysconf(_SC_PHYS_PAGES) is not supported");
116 mem = page_size * num_pages;
118 return mem / 100 * percent;
140 "Unknown argument for -l %s; generic assumed\n", options->
buffer_type);
166 WARN(
"cannot use O_DIRECT");
167 # define O_DIRECT 000000 169 # define O_DIRECT O_DIRECTIO 186 static time_t currentTime;
187 char* currentTimePtr;
189 if ((currentTime = time(
NULL)) == -1)
190 ERR(
"cannot get current time");
192 #if (_POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE || _POSIX_SOURCE) 193 static char threadSafeBuff[32];
194 if ((currentTimePtr = ctime_r(¤tTime, threadSafeBuff)) ==
NULL) {
195 ERR(
"cannot read current time");
198 if ((currentTimePtr = ctime(¤tTime)) ==
NULL) {
199 ERR(
"cannot read current time");
203 return (currentTimePtr);
217 for (i = 0; i < ((size /
sizeof(
IOR_size_t)) / 4); i++) {
218 for (j = 0; j < 4; j++) {
233 MPI_Comm_size(comm, &num_ranks);
234 int *node_map = (
int*)malloc(
sizeof(
int) * num_ranks);
239 FAIL(
"gethostname()");
246 MPI_Bcast(roothost,
MAX_PATHLEN, MPI_CHAR, 0, comm);
249 int same_as_root = strcmp(roothost,localhost) == 0;
250 MPI_Gather( &same_as_root, 1, MPI_INT, node_map, 1, MPI_INT, 0, comm);
251 if ( print_nodemap &&
rank==0) {
253 for (
int i = 0; i < num_ranks; i++ ) {
260 ret = node_map[1] == 1;
261 MPI_Bcast(&ret, 1, MPI_INT, 0, comm);
275 if (getenv(
"IOR_FAKE_NODES")){
276 int numNodes = atoi(getenv(
"IOR_FAKE_NODES"));
278 MPI_Comm_rank(comm, & rank);
280 printf(
"Fake number of node: using %d\n", numNodes);
285 MPI_Comm shared_comm;
287 int local_result = 0;
290 MPI_CHECK(MPI_Comm_split_type(comm, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &shared_comm),
291 "MPI_Comm_split_type() error");
292 MPI_CHECK(MPI_Comm_rank(shared_comm, &shared_rank),
"MPI_Comm_rank() error");
293 local_result = shared_rank == 0? 1 : 0;
294 MPI_CHECK(MPI_Allreduce(&local_result, &numNodes, 1, MPI_INT, MPI_SUM, comm),
295 "MPI_Allreduce() error");
296 MPI_CHECK(MPI_Comm_free(&shared_comm),
"MPI_Comm_free() error");
301 int numTasksOnNode0 = 0;
306 return ((numTasks - 1) / numTasksOnNode0) + 1;
314 MPI_CHECK(MPI_Comm_size(comm, &numTasks),
"cannot get number of tasks");
350 if (getenv(
"IOR_FAKE_TASK_PER_NODES")){
351 int tasksPerNode = atoi(getenv(
"IOR_FAKE_TASK_PER_NODES"));
353 MPI_Comm_rank(comm, & rank);
355 printf(
"Fake tasks per node: using %d\n", tasksPerNode);
360 MPI_Comm shared_comm;
362 int tasks_on_node_rank0 = 0;
363 int local_result = 0;
365 MPI_CHECK(MPI_Comm_split_type(comm, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &shared_comm),
366 "MPI_Comm_split_type() error");
367 MPI_CHECK(MPI_Comm_rank(shared_comm, &shared_rank),
"MPI_Comm_rank() error");
368 if (
rank == 0 && shared_rank == 0) {
369 MPI_CHECK(MPI_Comm_size(shared_comm, &local_result),
"MPI_Comm_size() error");
371 MPI_CHECK(MPI_Allreduce(&local_result, &tasks_on_node_rank0, 1, MPI_INT, MPI_SUM, comm),
372 "MPI_Allreduce() error");
373 MPI_CHECK(MPI_Comm_free(&shared_comm),
"MPI_Comm_free() error");
375 return tasks_on_node_rank0;
387 MPI_Comm_size(comm, & size);
396 fprintf(
out_logfile,
"V-1: Entering count_tasks_per_node...\n" );
401 FAIL(
"gethostname()");
405 for (i = 0; i < size-1; i++) {
406 MPI_Recv(hostname,
MAX_PATHLEN, MPI_CHAR, MPI_ANY_SOURCE,
407 MPI_ANY_TAG, comm, &status);
408 if (strcmp(hostname, localhost) == 0) {
414 MPI_Send(localhost,
MAX_PATHLEN, MPI_CHAR, 0, 0, comm);
416 MPI_Bcast(&count, 1, MPI_INT, 0, comm);
426 void ExtractHint(
char *settingVal,
char *valueVal,
char *hintString)
428 char *settingPtr, *valuePtr, *tmpPtr2;
431 settingPtr = (
char *)strtok(hintString,
" =");
432 valuePtr = (
char *)strtok(
NULL,
" =\t\r\n");
434 tmpPtr2 = (
char *) strstr(settingPtr,
"IOR_HINT__MPI__");
435 if (settingPtr == tmpPtr2) {
436 settingPtr += strlen(
"IOR_HINT__MPI__");
438 tmpPtr2 = (
char *) strstr(hintString,
"IOR_HINT__GPFS__");
440 if (settingPtr == tmpPtr2) {
441 settingPtr += strlen(
"IOR_HINT__GPFS__");
443 fprintf(
out_logfile,
"WARNING: Unable to set unknown hint type (not implemented.)\n");
447 strcpy(settingVal, settingPtr);
448 strcpy(valueVal, valuePtr);
454 void SetHints(MPI_Info * mpiHints,
char *hintsFileName)
471 MPI_CHECK(MPI_Info_create(mpiHints),
"cannot create info object");
474 for (i = 0; environ[i] !=
NULL; i++) {
476 if (strncmp(environ[i],
"IOR_HINT", strlen(
"IOR_HINT")) == 0) {
477 strcpy(hintString, environ[i]);
479 MPI_CHECK(MPI_Info_set(*mpiHints, settingVal, valueVal),
480 "cannot set info object");
485 if (hintsFileName !=
NULL && strcmp(hintsFileName,
"") != 0) {
488 fd = fopen(hintsFileName,
"r");
490 WARN(
"cannot open hints file");
495 (hintString,
"IOR_HINT",
496 strlen(
"IOR_HINT")) == 0) {
500 (*mpiHints, settingVal,
502 "cannot set info object");
507 ERR(
"cannot close hints file");
517 char key[MPI_MAX_INFO_VAL];
518 char value[MPI_MAX_INFO_VAL];
521 MPI_CHECK(MPI_Info_get_nkeys(*mpiHints, &nkeys),
522 "cannot get info object keys");
524 for (i = 0; i < nkeys; i++) {
525 MPI_CHECK(MPI_Info_get_nthkey(*mpiHints, i, key),
526 "cannot get info object key");
527 MPI_CHECK(MPI_Info_get(*mpiHints, key, MPI_MAX_INFO_VAL - 1,
529 "cannot get info object value");
543 rc = sscanf(size_str,
"%lld%c", &size, &range);
545 switch ((
int)range) {
559 }
else if (rc == 0) {
572 char *fileSystemUnitStr;
573 long long int totalFileSystemSize;
574 long long int freeFileSystemSize;
575 long long int totalInodes;
576 long long int freeInodes;
577 double totalFileSystemSizeHR;
578 double usedFileSystemPercentage;
579 double usedInodePercentage;
581 struct statvfs statusBuffer;
583 struct statfs statusBuffer;
587 if (statvfs(fileSystem, &statusBuffer) != 0) {
588 WARN(
"unable to statvfs() file system");
592 if (statfs(fileSystem, &statusBuffer) != 0) {
593 WARN(
"unable to statfs() file system");
600 totalFileSystemSize = statusBuffer.f_blocks * statusBuffer.f_frsize;
601 freeFileSystemSize = statusBuffer.f_bfree * statusBuffer.f_frsize;
603 totalFileSystemSize = statusBuffer.f_blocks * statusBuffer.f_bsize;
604 freeFileSystemSize = statusBuffer.f_bfree * statusBuffer.f_bsize;
607 usedFileSystemPercentage = (1 - ((double)freeFileSystemSize
608 / (
double)totalFileSystemSize)) * 100;
609 totalFileSystemSizeHR =
610 (double)totalFileSystemSize / (
double)(1<<30);
611 fileSystemUnitStr =
"GiB";
612 if (totalFileSystemSizeHR > 1024) {
613 totalFileSystemSizeHR = (double)totalFileSystemSize / (
double)((
long long)1<<40);
614 fileSystemUnitStr =
"TiB";
618 totalInodes = statusBuffer.f_files;
619 freeInodes = statusBuffer.f_ffree;
620 usedInodePercentage =
621 (1 - ((double)freeInodes / (
double)totalInodes)) * 100;
624 if (realpath(fileSystem, realPath) ==
NULL) {
625 WARN(
"unable to use realpath()");
632 "FS", totalFileSystemSizeHR, fileSystemUnitStr,
633 usedFileSystemPercentage);
635 (
double)totalInodes / (
double)(1<<20),
636 usedInodePercentage);
640 fprintf(
out_resultfile,
"\"Capacity\": \"%.1f %s\", \"Used Capacity\": \"%2.1f%%\",",
641 totalFileSystemSizeHR, fileSystemUnitStr,
642 usedFileSystemPercentage);
643 fprintf(
out_resultfile,
"\"Inodes\": \"%.1f Mi\", \"Used Inodes\" : \"%2.1f%%\"\n",
644 (
double)totalInodes / (
double)(1<<20),
645 usedInodePercentage);
658 int Regex(
char *
string,
char *pattern)
665 regcomp(®Ex, pattern, REG_EXTENDED);
666 if (regexec(®Ex,
string, 1, ®Match, 0) == 0) {
680 unsigned int randomSeed;
686 struct timeval randGenTimer;
687 gettimeofday(&randGenTimer, (
struct timezone *)
NULL);
688 randomSeed = randGenTimer.tv_usec;
691 MPI_CHECK(MPI_Bcast(&randomSeed, 1, MPI_INT, 0,
692 testComm),
"cannot broadcast random seed value");
700 int uname(
struct utsname *name)
702 DWORD nodeNameSize =
sizeof(name->nodename) - 1;
704 memset(name, 0,
sizeof(
struct utsname));
705 if (!GetComputerNameEx
706 (ComputerNameDnsFullyQualified, name->nodename, &nodeNameSize))
707 ERR(
"GetComputerNameEx failed");
709 strncpy(name->sysname,
"Windows",
sizeof(name->sysname) - 1);
711 strncpy(name->release,
"-",
sizeof(name->release) - 1);
712 strncpy(name->version,
"-",
sizeof(name->version) - 1);
713 strncpy(name->machine,
"-",
sizeof(name->machine) - 1);
730 struct timeval timer;
732 if (gettimeofday(&timer, (
struct timezone *)
NULL) != 0)
733 ERR(
"cannot use gettimeofday()");
734 timeVal = (double)timer.tv_sec + ((
double)timer.tv_usec / 1000000);
736 timeVal = MPI_Wtime();
738 ERR(
"cannot use MPI_Wtime()");
755 double roottimestamp;
759 MPI_CHECK(MPI_Reduce(×tamp, &min, 1, MPI_DOUBLE,
761 "cannot reduce tasks' times");
762 MPI_CHECK(MPI_Reduce(×tamp, &max, 1, MPI_DOUBLE,
764 "cannot reduce tasks' times");
769 "cannot broadcast root's time");
781 static char datestring[80];
782 time_t cur_timestamp;
785 fprintf(
out_logfile,
"V-1: Entering PrintTimestamp...\n" );
789 cur_timestamp = time(
NULL);
790 strftime(datestring, 80,
"%m/%d/%Y %T", localtime(&cur_timestamp));
801 FILE * out = fopen(filename,
"r");
807 int ret = fscanf(out,
"%lld", & data);
821 FILE * out = fopen(filename,
"w");
823 FAIL(
"Cannot write to the stonewalling file!");
825 fprintf(out,
"%lld", (
long long) count);
833 if (
rank == 0 && delay > 0) {
835 fprintf(
out_logfile,
"delaying %d seconds . . .\n", delay);
849 char m_str[8], g_str[8], t_str[8];
855 strcpy(m_str,
"MiB");
856 strcpy(g_str,
"GiB");
857 strcpy(t_str,
"TiB");
869 snprintf(valueStr,
MAX_STR-1,
"%.2f %s",
870 (
double)((
double)value / t), t_str);
872 snprintf(valueStr,
MAX_STR-1,
"%d %s", (
int)(value / t), t_str);
874 }
else if (value >= g) {
876 snprintf(valueStr,
MAX_STR-1,
"%.2f %s",
877 (
double)((
double)value / g), g_str);
879 snprintf(valueStr,
MAX_STR-1,
"%d %s", (
int)(value / g), g_str);
881 }
else if (value >= m) {
883 snprintf(valueStr,
MAX_STR-1,
"%.2f %s",
884 (
double)((
double)value / m), m_str);
886 snprintf(valueStr,
MAX_STR-1,
"%d %s", (
int)(value / m), m_str);
888 }
else if (value >= 0) {
889 snprintf(valueStr,
MAX_STR-1,
"%d bytes", (
int)value);
891 snprintf(valueStr,
MAX_STR-1,
"-");
char * HumanReadable(IOR_offset_t value, int base)
int GetNumTasks(MPI_Comm comm)
void set_o_direct_flag(int *fd)
void ShowHints(MPI_Info *mpiHints)
unsigned int incompressibleSeed
void * airoi_update_module_options(const ior_aiori_t *backend, options_all_t *opt)
char *(* get_version)(void)
int64_t ReadStoneWallingIterations(char *const filename)
enum OutputFormat_t outputFormat
int QueryNodeMapping(MPI_Comm comm, int print_nodemap)
int setTimeStampSignature
IOR_offset_t StringToBytes(char *size_str)
static double TimeDeviation(void)
const ior_aiori_t * aiori_select(const char *api)
void ShowFileSystemSize(char *fileSystem)
static option_help options[]
void SeedRandGen(MPI_Comm testComm)
char * CurrentTimeString(void)
#define MPI_CHECK(MPI_STATUS, MSG)
double wall_clock_deviation
void updateParsedOptions(IOR_param_t *options, options_all_t *global_options)
int GetNumNodes(MPI_Comm comm)
double GetTimeStamp(void)
static const ior_aiori_t * backend
void StoreStoneWallingIterations(char *const filename, int64_t count)
static char hostname[MAX_PATHLEN]
enum PACKET_TYPE dataPacketType
static options_all_t * global_options
int64_t string_to_bytes(char *size_str)
void ExtractHint(char *settingVal, char *valueVal, char *hintString)
const struct ior_aiori * backend
void SetHints(MPI_Info *mpiHints, char *hintsFileName)
void FailMessage(int rank, const char *location, char *format,...)
void DelaySecs(int delay)
int Regex(char *string, char *pattern)
size_t NodeMemoryStringToBytes(char *size_str)
void DumpBuffer(void *buffer, size_t size)
long long int IOR_offset_t
int GetNumTasksOnNode0(MPI_Comm comm)
void * safeMalloc(uint64_t size)