Create random for one block (1 segment) only to be repeated.
parent
3ee3e9ad5c
commit
a0e5e297d6
|
@ -25,8 +25,7 @@ void PrintTestEnds();
|
||||||
void PrintTableHeader();
|
void PrintTableHeader();
|
||||||
/* End of ior-output */
|
/* End of ior-output */
|
||||||
|
|
||||||
IOR_offset_t *GetOffsetArraySequential(IOR_param_t * test, int pretendRank);
|
IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank);
|
||||||
IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank, int access);
|
|
||||||
|
|
||||||
struct results {
|
struct results {
|
||||||
double min;
|
double min;
|
||||||
|
|
96
src/ior.c
96
src/ior.c
|
@ -1025,9 +1025,6 @@ static void InitTests(IOR_test_t *tests, MPI_Comm com)
|
||||||
}
|
}
|
||||||
|
|
||||||
init_clock();
|
init_clock();
|
||||||
|
|
||||||
/* seed random number generator */
|
|
||||||
SeedRandGen(mpi_comm_world);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1645,11 +1642,10 @@ static void ValidateTests(IOR_param_t * test)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a precomputed array of IOR_offset_t for the inner benchmark loop.
|
* Returns a precomputed array of IOR_offset_t for the inner benchmark loop terminated by offset -1.
|
||||||
* They get created sequentially and mixed up in the end. The last array element
|
* They get created sequentially and mixed up in the end.
|
||||||
* is set to -1 as end marker.
|
* It should be noted that as the seeds get synchronised across all processes if not FilePerProcess is set
|
||||||
* It should be noted that as the seeds get synchronised across all processes
|
* every process computes the same random order.
|
||||||
* every process computes the same random order if used with filePerProc.
|
|
||||||
* For a shared file all transfers get randomly assigned to ranks. The processes
|
* For a shared file all transfers get randomly assigned to ranks. The processes
|
||||||
* can also have differen't numbers of transfers. This might lead to a bigger
|
* can also have differen't numbers of transfers. This might lead to a bigger
|
||||||
* diversion in accesse as it dose with filePerProc. This is expected but
|
* diversion in accesse as it dose with filePerProc. This is expected but
|
||||||
|
@ -1657,73 +1653,79 @@ static void ValidateTests(IOR_param_t * test)
|
||||||
* @param test IOR_param_t for getting transferSize, blocksize and SegmentCount
|
* @param test IOR_param_t for getting transferSize, blocksize and SegmentCount
|
||||||
* @param pretendRank int pretended Rank for shifting the offsets correctly
|
* @param pretendRank int pretended Rank for shifting the offsets correctly
|
||||||
* @return IOR_offset_t
|
* @return IOR_offset_t
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank, int access)
|
IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank)
|
||||||
{
|
{
|
||||||
int seed;
|
int seed;
|
||||||
IOR_offset_t i, value, tmp;
|
IOR_offset_t i;
|
||||||
IOR_offset_t offsets = 0;
|
IOR_offset_t offsets;
|
||||||
IOR_offset_t offsetCnt = 0;
|
IOR_offset_t offsetCnt = 0;
|
||||||
IOR_offset_t fileSize;
|
|
||||||
IOR_offset_t *offsetArray;
|
IOR_offset_t *offsetArray;
|
||||||
|
|
||||||
/* set up seed, each process can determine which regions to access individually */
|
if (test->filePerProc) {
|
||||||
if (test->randomSeed == -1) {
|
/* set up seed, each process can determine which regions to access individually */
|
||||||
test->randomSeed = seed = rand();
|
if (test->randomSeed == -1) {
|
||||||
} else {
|
seed = time(NULL);
|
||||||
seed = test->randomSeed + pretendRank;
|
test->randomSeed = seed;
|
||||||
}
|
} else {
|
||||||
srand(seed);
|
seed = test->randomSeed + pretendRank;
|
||||||
|
}
|
||||||
fileSize = test->blockSize * test->segmentCount;
|
}else{
|
||||||
if (test->filePerProc == FALSE) {
|
/* Shared file requires that the seed is synchronized */
|
||||||
fileSize *= test->numTasks;
|
if (test->randomSeed == -1) {
|
||||||
|
// all processes need to have the same seed.
|
||||||
|
if(rank == 0){
|
||||||
|
seed = time(NULL);
|
||||||
|
}
|
||||||
|
MPI_CHECK(MPI_Bcast(& seed, 1, MPI_INT, 0, test->testComm), "cannot broadcast random seed value");
|
||||||
|
test->randomSeed = seed;
|
||||||
|
}else{
|
||||||
|
seed = test->randomSeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
srandom(seed);
|
||||||
|
|
||||||
/* count needed offsets (pass 1) */
|
/* count needed offsets (pass 1) */
|
||||||
if (test->filePerProc == FALSE) {
|
if (test->filePerProc == FALSE) {
|
||||||
for (i = 0; i < fileSize; i += test->transferSize) {
|
offsets = 0;
|
||||||
// this counts which process get how many transferes in
|
for (i = 0; i < test->blockSize; i += test->transferSize) {
|
||||||
// a shared file
|
// this counts which process get how many transferes in the shared file
|
||||||
if ((rand() % test->numTasks) == pretendRank) {
|
if ((rand() % test->numTasks) == pretendRank) {
|
||||||
offsets++;
|
offsets++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
offsets += fileSize / test->transferSize;
|
offsets = test->blockSize / test->transferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* setup empty array */
|
/* setup empty array */
|
||||||
offsetArray =
|
offsetArray = (IOR_offset_t *) safeMalloc((offsets + 1) * sizeof(IOR_offset_t));
|
||||||
(IOR_offset_t *) malloc((offsets + 1) * sizeof(IOR_offset_t));
|
|
||||||
if (offsetArray == NULL)
|
|
||||||
ERR("malloc() failed");
|
|
||||||
offsetArray[offsets] = -1; /* set last offset with -1 */
|
offsetArray[offsets] = -1; /* set last offset with -1 */
|
||||||
|
|
||||||
if (test->filePerProc) {
|
if (test->filePerProc) {
|
||||||
/* fill array */
|
/* fill array */
|
||||||
for (i = 0; i < offsets; i++) {
|
for (i = 0; i < offsets; i++) {
|
||||||
offsetArray[i] = i * test->transferSize;
|
offsetArray[i] = i * test->transferSize;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* fill with offsets (pass 2) */
|
/* fill with offsets (pass 2) */
|
||||||
srand(seed); /* need same seedto get same transfers as counted in the beginning*/
|
srandom(seed); /* need same seed to get same transfers as counted in the beginning*/
|
||||||
for (i = 0; i < fileSize; i += test->transferSize) {
|
for (i = 0; i < test->blockSize; i += test->transferSize) {
|
||||||
if ((rand() % test->numTasks) == pretendRank) {
|
if ((rand() % test->numTasks) == pretendRank) {
|
||||||
offsetArray[offsetCnt] = i;
|
offsetArray[offsetCnt] = i;
|
||||||
offsetCnt++;
|
offsetCnt++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* reorder array */
|
/* reorder array */
|
||||||
for (i = 0; i < offsets; i++) {
|
for (i = 0; i < offsets; i++) {
|
||||||
|
IOR_offset_t value, tmp;
|
||||||
value = rand() % offsets;
|
value = rand() % offsets;
|
||||||
tmp = offsetArray[value];
|
tmp = offsetArray[value];
|
||||||
offsetArray[value] = offsetArray[i];
|
offsetArray[value] = offsetArray[i];
|
||||||
offsetArray[i] = tmp;
|
offsetArray[i] = tmp;
|
||||||
}
|
}
|
||||||
SeedRandGen(test->testComm); /* synchronize seeds across tasks */
|
|
||||||
|
|
||||||
return (offsetArray);
|
return (offsetArray);
|
||||||
}
|
}
|
||||||
|
|
|
@ -654,27 +654,6 @@ int Regex(char *string, char *pattern)
|
||||||
return (retValue);
|
return (retValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Seed random generator.
|
|
||||||
*/
|
|
||||||
void SeedRandGen(MPI_Comm testComm)
|
|
||||||
{
|
|
||||||
unsigned int randomSeed;
|
|
||||||
|
|
||||||
if (rank == 0) {
|
|
||||||
#ifdef _WIN32
|
|
||||||
rand_s(&randomSeed);
|
|
||||||
#else
|
|
||||||
struct timeval randGenTimer;
|
|
||||||
gettimeofday(&randGenTimer, (struct timezone *)NULL);
|
|
||||||
randomSeed = randGenTimer.tv_usec;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
MPI_CHECK(MPI_Bcast(&randomSeed, 1, MPI_INT, 0,
|
|
||||||
testComm), "cannot broadcast random seed value");
|
|
||||||
srandom(randomSeed);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* System info for Windows.
|
* System info for Windows.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -46,7 +46,6 @@ char *CurrentTimeString(void);
|
||||||
int Regex(char *, char *);
|
int Regex(char *, char *);
|
||||||
void ShowFileSystemSize(IOR_param_t * test);
|
void ShowFileSystemSize(IOR_param_t * test);
|
||||||
void DumpBuffer(void *, size_t);
|
void DumpBuffer(void *, size_t);
|
||||||
void SeedRandGen(MPI_Comm);
|
|
||||||
void SetHints (MPI_Info *, char *);
|
void SetHints (MPI_Info *, char *);
|
||||||
void ShowHints (MPI_Info *);
|
void ShowHints (MPI_Info *);
|
||||||
char *HumanReadable(IOR_offset_t value, int base);
|
char *HumanReadable(IOR_offset_t value, int base);
|
||||||
|
|
Loading…
Reference in New Issue