Skip to content

Commit

Permalink
Adding ALWAYS_VALIDATE to allow per-iteration validation (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilbertlee-amd authored Oct 30, 2023
1 parent 9c2ecae commit 1d34a19
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for TransferBench

## v1.33
### Added
- Adding ALWAYS_VALIDATE env var to allow for validation after every iteration instead of just once at end of all iterations

## v1.32
### Modified
- Increased line limit from 2048 to 32768
Expand Down
10 changes: 9 additions & 1 deletion src/TransferBench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,15 @@ void ExecuteTransfers(EnvVars const& ev,
auto cpuDelta = std::chrono::high_resolution_clock::now() - cpuStart;
double deltaSec = std::chrono::duration_cast<std::chrono::duration<double>>(cpuDelta).count();

if (ev.alwaysValidate)
{
for (auto transferPair : transferList)
{
Transfer* transfer = transferPair.second;
transfer->ValidateDst(ev);
}
}

if (iteration >= 0)
{
++numTimedIterations;
Expand All @@ -494,7 +503,6 @@ void ExecuteTransfers(EnvVars const& ev,
// Validate that each transfer has transferred correctly
size_t totalBytesTransferred = 0;
int const numTransfers = transferList.size();

for (auto transferPair : transferList)
{
Transfer* transfer = transferPair.second;
Expand Down
8 changes: 6 additions & 2 deletions src/include/EnvVars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ THE SOFTWARE.
#include "Compatibility.hpp"
#include "Kernels.hpp"

#define TB_VERSION "1.32"
#define TB_VERSION "1.33"

extern char const MemTypeStr[];
extern char const ExeTypeStr[];
Expand Down Expand Up @@ -72,6 +72,7 @@ class EnvVars
int const DEFAULT_SWEEP_TIME_LIMIT = 0;

// Environment variables
int alwaysValidate; // Validate after each iteration instead of once after all iterations
int blockSize; // Size of each threadblock (must be multiple of 64)
int blockBytes; // Each CU, except the last, gets a multiple of this many bytes to copy
int blockOrder; // How blocks are ordered in single-stream mode (0=Sequential, 1=Interleaved, 2=Random)
Expand Down Expand Up @@ -166,6 +167,7 @@ class EnvVars
else if (archName == "gfx940") defaultGpuKernel = 6;
else if (archName == "gfx941") defaultGpuKernel = 6;

alwaysValidate = GetEnvVar("ALWAYS_VALIDATE" , 0);
blockSize = GetEnvVar("BLOCK_SIZE" , 256);
blockBytes = GetEnvVar("BLOCK_BYTES" , 256);
blockOrder = GetEnvVar("BLOCK_ORDER" , 0);
Expand Down Expand Up @@ -479,6 +481,7 @@ class EnvVars
{
printf("Environment variables:\n");
printf("======================\n");
printf(" ALWAYS_VALIDATE - Validate after each iteration instead of once after all iterations\n");
printf(" BLOCK_SIZE - # of threads per threadblock (Must be multiple of 64). Defaults to 256\n");
printf(" BLOCK_BYTES - Each CU (except the last) receives a multiple of BLOCK_BYTES to copy\n");
printf(" BLOCK_ORDER - Threadblock ordering in single-stream mode (0=Serial, 1=Interleaved, 2=Random)\n");
Expand Down Expand Up @@ -521,7 +524,8 @@ class EnvVars
else if (!hideEnv)
printf("EnvVar,Value,Description,(TransferBench v%s)\n", TB_VERSION);
if (hideEnv) return;

PRINT_EV("ALWAYS_VALIDATE", alwaysValidate,
std::string("Validating after ") + (alwaysValidate ? "each iteration" : "all iterations"));
PRINT_EV("BLOCK_SIZE", blockSize,
std::string("Threadblock size of " + std::to_string(blockSize)));
PRINT_EV("BLOCK_BYTES", blockBytes,
Expand Down

0 comments on commit 1d34a19

Please sign in to comment.