1
- /* -*- mode: c; c-basic-offset: 8 ; indent-tabs-mode: nil; -*-
2
- * vim:expandtab:shiftwidth=8 :tabstop=8 :
1
+ /* -*- mode: c; c-basic-offset: 2 ; indent-tabs-mode: nil; -*-
2
+ * vim:expandtab:shiftwidth=2 :tabstop=2 :
3
3
*/
4
4
/******************************************************************************\
5
5
* *
@@ -1401,6 +1401,9 @@ static void TestIoSys(IOR_test_t *test)
1401
1401
}
1402
1402
/* Using globally passed rankOffset, following function generates testFileName to read */
1403
1403
GetTestFileName (testFileName , params );
1404
+ if (params -> randomOffset > 1 ){
1405
+ params -> expectedAggFileSize = backend -> get_file_size (params -> backend_options , testFileName );
1406
+ }
1404
1407
1405
1408
if (verbose >= VERBOSE_3 ) {
1406
1409
fprintf (out_logfile , "task %d reading %s\n" , rank ,
@@ -1520,7 +1523,7 @@ static void ValidateTests(IOR_param_t * test, MPI_Comm com)
1520
1523
}
1521
1524
if (test -> blockSize < test -> transferSize )
1522
1525
ERR ("block size must not be smaller than transfer size" );
1523
- if (test -> randomOffset && test -> blockSize == test -> transferSize )
1526
+ if (test -> randomOffset == 1 && test -> blockSize == test -> transferSize )
1524
1527
ERR ("IOR will randomize access within a block and repeats the same pattern for all segments, therefore choose blocksize > transferSize" );
1525
1528
if (! test -> randomOffset && test -> randomPrefillBlocksize )
1526
1529
ERR ("Setting the randomPrefill option without using random is not useful" );
@@ -1583,6 +1586,33 @@ static void ValidateTests(IOR_param_t * test, MPI_Comm com)
1583
1586
}
1584
1587
}
1585
1588
1589
+ static int init_random_seed (IOR_param_t * test , int pretendRank ){
1590
+ int seed ;
1591
+ if (test -> filePerProc ) {
1592
+ /* set up seed, each process can determine which regions to access individually */
1593
+ if (test -> randomSeed == -1 ) {
1594
+ seed = time (NULL );
1595
+ test -> randomSeed = seed ;
1596
+ } else {
1597
+ seed = test -> randomSeed + pretendRank ;
1598
+ }
1599
+ }else {
1600
+ /* Shared file requires that the seed is synchronized */
1601
+ if (test -> randomSeed == -1 ) {
1602
+ // all processes need to have the same seed.
1603
+ if (rank == 0 ){
1604
+ seed = time (NULL );
1605
+ }
1606
+ MPI_CHECK (MPI_Bcast (& seed , 1 , MPI_INT , 0 , test -> testComm ), "cannot broadcast random seed value" );
1607
+ test -> randomSeed = seed ;
1608
+ }else {
1609
+ seed = test -> randomSeed ;
1610
+ }
1611
+ }
1612
+ srandom (seed );
1613
+ return seed ;
1614
+ }
1615
+
1586
1616
/**
1587
1617
* Returns a precomputed array of IOR_offset_t for the inner benchmark loop.
1588
1618
* They get created sequentially and mixed up in the end.
@@ -1604,28 +1634,7 @@ IOR_offset_t *GetOffsetArrayRandom(IOR_param_t * test, int pretendRank, IOR_offs
1604
1634
IOR_offset_t offsetCnt = 0 ;
1605
1635
IOR_offset_t * offsetArray ;
1606
1636
1607
- if (test -> filePerProc ) {
1608
- /* set up seed, each process can determine which regions to access individually */
1609
- if (test -> randomSeed == -1 ) {
1610
- seed = time (NULL );
1611
- test -> randomSeed = seed ;
1612
- } else {
1613
- seed = test -> randomSeed + pretendRank ;
1614
- }
1615
- }else {
1616
- /* Shared file requires that the seed is synchronized */
1617
- if (test -> randomSeed == -1 ) {
1618
- // all processes need to have the same seed.
1619
- if (rank == 0 ){
1620
- seed = time (NULL );
1621
- }
1622
- MPI_CHECK (MPI_Bcast (& seed , 1 , MPI_INT , 0 , test -> testComm ), "cannot broadcast random seed value" );
1623
- test -> randomSeed = seed ;
1624
- }else {
1625
- seed = test -> randomSeed ;
1626
- }
1627
- }
1628
- srandom (seed );
1637
+ seed = init_random_seed (test , pretendRank );
1629
1638
1630
1639
/* count needed offsets (pass 1) */
1631
1640
if (test -> filePerProc ) {
@@ -1766,11 +1775,15 @@ static IOR_offset_t WriteOrRead(IOR_param_t *test, int rep, IOR_results_t *resul
1766
1775
1767
1776
IOR_offset_t offsets ;
1768
1777
IOR_offset_t * offsets_rnd ;
1769
- if (test -> randomOffset ) {
1778
+ if (test -> randomOffset == 1 ) {
1770
1779
offsets_rnd = GetOffsetArrayRandom (test , pretendRank , & offsets );
1771
1780
}else {
1772
1781
offsets = (test -> blockSize / test -> transferSize );
1773
1782
}
1783
+ if (test -> randomOffset > 1 ){
1784
+ int seed = init_random_seed (test , pretendRank );
1785
+ srand (seed + pretendRank );
1786
+ }
1774
1787
1775
1788
void * randomPrefillBuffer = NULL ;
1776
1789
if (test -> randomPrefillBlocksize && (access == WRITE || access == WRITECHECK )){
@@ -1799,9 +1812,9 @@ static IOR_offset_t WriteOrRead(IOR_param_t *test, int rep, IOR_results_t *resul
1799
1812
// must synchronize processes to ensure they are not running ahead
1800
1813
MPI_Barrier (test -> testComm );
1801
1814
}
1802
-
1803
1815
do { // to ensure the benchmark runs a certain time
1804
1816
for (i = 0 ; i < test -> segmentCount && !hitStonewall ; i ++ ) {
1817
+ IOR_offset_t offset ;
1805
1818
if (randomPrefillBuffer && test -> deadlineForStonewalling != 0 ){
1806
1819
// prefill the whole segment with data, this needs to be done collectively
1807
1820
double t_start = GetTimeStamp ();
@@ -1811,14 +1824,27 @@ static IOR_offset_t WriteOrRead(IOR_param_t *test, int rep, IOR_results_t *resul
1811
1824
fprintf (out_logfile , "Random: synchronizing segment count with barrier and prefill took: %fs\n" , GetTimeStamp () - t_start );
1812
1825
}
1813
1826
}
1827
+ if (test -> randomOffset > 1 ){
1828
+ size_t sizerand = test -> expectedAggFileSize ;
1829
+ if (test -> filePerProc ){
1830
+ sizerand /= test -> numTasks ;
1831
+ }
1832
+ offset = rand () % (sizerand / test -> blockSize ) * test -> blockSize - test -> transferSize ;
1833
+ if (i == 0 && access == WRITE ){ // always write the last block first
1834
+ if (test -> filePerProc || rank == 0 ){
1835
+ offset = (sizerand / test -> blockSize - 1 ) * test -> blockSize - test -> transferSize ;
1836
+ }
1837
+ }
1838
+ }
1814
1839
for (j = 0 ; j < offsets && !hitStonewall ; j ++ ) {
1815
- IOR_offset_t offset ;
1816
- if (test -> randomOffset ) {
1840
+ if (test -> randomOffset == 1 ) {
1817
1841
if (test -> filePerProc ){
1818
1842
offset = offsets_rnd [j ] + (i * test -> blockSize );
1819
1843
}else {
1820
1844
offset = offsets_rnd [j ] + (i * test -> numTasks * test -> blockSize );
1821
1845
}
1846
+ }else if (test -> randomOffset > 1 ){
1847
+ offset += test -> transferSize ;
1822
1848
}else {
1823
1849
offset = j * test -> transferSize ;
1824
1850
if (test -> filePerProc ) {
@@ -1873,15 +1899,24 @@ static IOR_offset_t WriteOrRead(IOR_param_t *test, int rep, IOR_results_t *resul
1873
1899
i ++ ;
1874
1900
}
1875
1901
for ( ; pairCnt < point -> pairs_accessed ; i ++ ) {
1902
+ IOR_offset_t offset ;
1876
1903
if (i == test -> segmentCount ) i = 0 ; // wrap over, necessary to deal with minTimeDuration
1904
+ if (test -> randomOffset > 1 ){
1905
+ size_t sizerand = test -> expectedAggFileSize ;
1906
+ if (test -> filePerProc ){
1907
+ sizerand /= test -> numTasks ;
1908
+ }
1909
+ offset = rand () % (sizerand / test -> blockSize ) * test -> blockSize - test -> transferSize ;
1910
+ }
1877
1911
for ( ; j < offsets && pairCnt < point -> pairs_accessed ; j ++ ) {
1878
- IOR_offset_t offset ;
1879
- if (test -> randomOffset ) {
1912
+ if (test -> randomOffset == 1 ) {
1880
1913
if (test -> filePerProc ){
1881
1914
offset = offsets_rnd [j ] + (i * test -> blockSize );
1882
1915
}else {
1883
1916
offset = offsets_rnd [j ] + (i * test -> numTasks * test -> blockSize );
1884
1917
}
1918
+ }else if (test -> randomOffset > 1 ){
1919
+ offset += test -> transferSize ;
1885
1920
}else {
1886
1921
offset = j * test -> transferSize ;
1887
1922
if (test -> filePerProc ) {
0 commit comments