@@ -176,6 +176,11 @@ void CmdLineParser::_DisplayUsageInfo(const char *pszFilename) const
176
176
printf (" -l Use large pages for IO buffers\n " );
177
177
printf (" -L measure latency statistics\n " );
178
178
printf (" -n disable default affinity (-a)\n " );
179
+ printf (" -N<vni> specify the flush mode for memory mapped I/O\n " );
180
+ printf (" v : uses the FlushViewOfFile API\n " );
181
+ printf (" n : uses the RtlFlushNonVolatileMemory API\n " );
182
+ printf (" i : uses RtlFlushNonVolatileMemory without waiting for the flush to drain\n " );
183
+ printf (" [default: none]\n " );
179
184
printf (" -o<count> number of outstanding I/O requests per target per thread\n " );
180
185
printf (" (1=synchronous I/O, unless more than 1 thread is specified with -F)\n " );
181
186
printf (" [default=2]\n " );
@@ -194,14 +199,16 @@ void CmdLineParser::_DisplayUsageInfo(const char *pszFilename) const
194
199
printf (" manipulate a shared offset with InterlockedIncrement, which may reduce throughput,\n " );
195
200
printf (" but promotes a more sequential pattern.\n " );
196
201
printf (" (ignored if -r specified, -si conflicts with -T and -p)\n " );
197
- printf (" -S[bhruw] control caching behavior [default: caching is enabled, no writethrough]\n " );
202
+ printf (" -S[bhmruw] control caching behavior [default: caching is enabled, no writethrough]\n " );
198
203
printf (" non-conflicting flags may be combined in any order; ex: -Sbw, -Suw, -Swu\n " );
199
204
printf (" -S equivalent to -Su\n " );
200
205
printf (" -Sb enable caching (default, explicitly stated)\n " );
201
206
printf (" -Sh equivalent -Suw\n " );
207
+ printf (" -Sm enable memory mapped I/O\n " );
202
208
printf (" -Su disable software caching, equivalent to FILE_FLAG_NO_BUFFERING\n " );
203
209
printf (" -Sr disable local caching, with remote sw caching enabled; only valid for remote filesystems\n " );
204
- printf (" -Sw enable writethrough (no hardware write caching), equivalent to FILE_FLAG_WRITE_THROUGH\n " );
210
+ printf (" -Sw enable writethrough (no hardware write caching), equivalent to FILE_FLAG_WRITE_THROUGH or\n " );
211
+ printf (" non-temporal writes for memory mapped I/O (-Sm)\n " );
205
212
printf (" -t<count> number of threads per target (conflicts with -F)\n " );
206
213
printf (" -T<offs>[K|M|G|b] starting stride between I/O operations performed on the same target by different threads\n " );
207
214
printf (" [default=0] (starting offset = base file offset + (thread number * <offs>)\n " );
@@ -480,6 +487,39 @@ bool CmdLineParser::_ParseAffinity(const char *arg, TimeSpan *pTimeSpan)
480
487
return fOk ;
481
488
}
482
489
490
+ bool CmdLineParser::_ParseFlushParameter (const char *arg, MemoryMappedIoFlushMode *FlushMode)
491
+ {
492
+ assert (nullptr != arg);
493
+ assert (0 != *arg);
494
+
495
+ bool fOk = true ;
496
+ if (*(arg + 1 ) != ' \0 ' )
497
+ {
498
+ const char *c = arg + 1 ;
499
+ if (_stricmp (c, " v" ) == 0 )
500
+ {
501
+ *FlushMode = MemoryMappedIoFlushMode::ViewOfFile;
502
+ }
503
+ else if (_stricmp (c, " n" ) == 0 )
504
+ {
505
+ *FlushMode = MemoryMappedIoFlushMode::NonVolatileMemory;
506
+ }
507
+ else if (_stricmp (c, " i" ) == 0 )
508
+ {
509
+ *FlushMode = MemoryMappedIoFlushMode::NonVolatileMemoryNoDrain;
510
+ }
511
+ else
512
+ {
513
+ fOk = false ;
514
+ }
515
+ }
516
+ else
517
+ {
518
+ fOk = false ;
519
+ }
520
+ return fOk ;
521
+ }
522
+
483
523
bool CmdLineParser::_ReadParametersFromCmdLine (const int argc, const char *argv[], Profile *pProfile, struct Synchronization *synch)
484
524
{
485
525
/* Process any command-line options */
@@ -530,6 +570,8 @@ bool CmdLineParser::_ReadParametersFromCmdLine(const int argc, const char *argv[
530
570
// this allows for conflicts to be thrown for mixed -h/-S as needed.
531
571
TargetCacheMode t = TargetCacheMode::Undefined;
532
572
WriteThroughMode w = WriteThroughMode::Undefined;
573
+ MemoryMappedIoMode m = MemoryMappedIoMode::Undefined;
574
+ MemoryMappedIoFlushMode f = MemoryMappedIoFlushMode::Undefined;
533
575
534
576
TimeSpan timeSpan;
535
577
bool bExit = false ;
@@ -837,6 +879,13 @@ bool CmdLineParser::_ReadParametersFromCmdLine(const int argc, const char *argv[
837
879
timeSpan.SetDisableAffinity (true );
838
880
break ;
839
881
882
+ case ' N' :
883
+ if (!_ParseFlushParameter (arg, &f))
884
+ {
885
+ fError = true ;
886
+ }
887
+ break ;
888
+
840
889
case ' o' : // request count (1==synchronous)
841
890
{
842
891
int c = atoi (arg + 1 );
@@ -989,14 +1038,27 @@ bool CmdLineParser::_ReadParametersFromCmdLine(const int argc, const char *argv[
989
1038
break ;
990
1039
case ' h' :
991
1040
if (t == TargetCacheMode::Undefined &&
992
- w == WriteThroughMode::Undefined)
1041
+ w == WriteThroughMode::Undefined &&
1042
+ m == MemoryMappedIoMode::Undefined)
993
1043
{
994
1044
t = TargetCacheMode::DisableOSCache;
995
1045
w = WriteThroughMode::On;
996
1046
}
997
1047
else
998
1048
{
999
- fprintf (stderr, " -Sh conflicts with earlier specification of cache/writethrough\n " );
1049
+ fprintf (stderr, " -Sh conflicts with earlier specification of cache/writethrough/memory mapped\n " );
1050
+ fError = true ;
1051
+ }
1052
+ break ;
1053
+ case ' m' :
1054
+ if (m == MemoryMappedIoMode::Undefined &&
1055
+ t != TargetCacheMode::DisableOSCache)
1056
+ {
1057
+ m = MemoryMappedIoMode::On;
1058
+ }
1059
+ else
1060
+ {
1061
+ fprintf (stderr, " -Sm conflicts with earlier specification of memory mapped IO/unbuffered IO\n " );
1000
1062
fError = true ;
1001
1063
}
1002
1064
break ;
@@ -1012,13 +1074,14 @@ bool CmdLineParser::_ReadParametersFromCmdLine(const int argc, const char *argv[
1012
1074
}
1013
1075
break ;
1014
1076
case ' u' :
1015
- if (t == TargetCacheMode::Undefined)
1077
+ if (t == TargetCacheMode::Undefined &&
1078
+ m == MemoryMappedIoMode::Undefined)
1016
1079
{
1017
1080
t = TargetCacheMode::DisableOSCache;
1018
1081
}
1019
1082
else
1020
1083
{
1021
- fprintf (stderr, " -Su conflicts with earlier specification of cache mode\n " );
1084
+ fprintf (stderr, " -Su conflicts with earlier specification of cache mode/memory mapped IO \n " );
1022
1085
fError = true ;
1023
1086
}
1024
1087
break ;
@@ -1043,7 +1106,8 @@ bool CmdLineParser::_ReadParametersFromCmdLine(const int argc, const char *argv[
1043
1106
// bare -S, parse loop did not advance
1044
1107
if (!fError && idx == 1 )
1045
1108
{
1046
- if (t == TargetCacheMode::Undefined)
1109
+ if (t == TargetCacheMode::Undefined &&
1110
+ m == MemoryMappedIoMode::Undefined)
1047
1111
{
1048
1112
t = TargetCacheMode::DisableOSCache;
1049
1113
}
@@ -1283,7 +1347,7 @@ bool CmdLineParser::_ReadParametersFromCmdLine(const int argc, const char *argv[
1283
1347
return false ;
1284
1348
}
1285
1349
1286
- // apply resultant cache/writethrough modes to the targets
1350
+ // apply resultant cache/writethrough/memory mapped io modes to the targets
1287
1351
for (auto i = vTargets.begin (); i != vTargets.end (); i++)
1288
1352
{
1289
1353
if (t != TargetCacheMode::Undefined)
@@ -1294,6 +1358,14 @@ bool CmdLineParser::_ReadParametersFromCmdLine(const int argc, const char *argv[
1294
1358
{
1295
1359
i->SetWriteThroughMode (w);
1296
1360
}
1361
+ if (m != MemoryMappedIoMode::Undefined)
1362
+ {
1363
+ i->SetMemoryMappedIoMode (m);
1364
+ }
1365
+ if (f != MemoryMappedIoFlushMode::Undefined)
1366
+ {
1367
+ i->SetMemoryMappedIoFlushMode (f);
1368
+ }
1297
1369
}
1298
1370
1299
1371
// ... and apply targets to the timespan
0 commit comments