[TransferBench] Updating for 2.8.3

This commit is contained in:
Gilbert Lee
2021-02-04 18:50:27 +00:00
parent 5f97122442
commit 9ce203dd0a
6 changed files with 832 additions and 809 deletions
+93 -35
View File
@@ -25,6 +25,7 @@ THE SOFTWARE.
#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <set>
#include <unistd.h>
#include <map>
@@ -33,7 +34,22 @@ THE SOFTWARE.
#include <hip/hip_runtime.h>
#include <hip/hip_ext.h>
#include <hsa/hsa_ext_amd.h>
#include "copy_kernel.h"
#include <hip/hcc_detail/hip_fp16.h>
// Include common_kernel.h from RCCL for copy kernel
// However define some variables to avoid extra includes / missing defines
#define NCCL_DEVICE_H_ // Avoid loading devcomm.h
#define WARP_SIZE 64
typedef uint64_t PackType;
typedef ulong2 Pack128;
typedef struct
{
uint16_t data;
} rccl_bfloat16;
#include "../../src/collectives/device/common_kernel.h"
#include "EnvVars.hpp"
// Helper macro for catching HIP errors
#define HIP_CALL(cmd) \
@@ -50,11 +66,12 @@ THE SOFTWARE.
// Different src/dst memory types supported
typedef enum
{
MEM_CPU = 0, // Pinned CPU memory
MEM_GPU = 1 // Global GPU memory
MEM_CPU = 0, // Pinned CPU memory
MEM_GPU = 1, // Coarse-grained global GPU memory
MEM_GPU_FINE = 2 // Fine-grained global GPU memory
} MemType;
char const MemTypeStr[3] = "CG";
char const MemTypeStr[4] = "CGF";
typedef enum
{
@@ -62,17 +79,6 @@ typedef enum
MODE_CHECK = 1 // Check data against pattern
} ModeType;
// Each Link is a uni-direction operation from a src memory to dst memory executed by a specific GPU
struct Link
{
int exeIndex; // GPU to execute on
MemType srcMemType; // Source memory type
int srcIndex; // Source device index
MemType dstMemType; // Destination memory type
int dstIndex; // Destination device index
int numBlocksToUse; // Number of threadblocks to use for this Link
};
// Each threadblock copies N floats from src to dst
struct BlockParam
{
@@ -81,46 +87,98 @@ struct BlockParam
float* dst;
};
// Each Link is a uni-direction operation from a src memory to dst memory executed by a specific GPU
struct Link
{
// Link config
MemType exeMemType; // Link executor type (CPU or GPU)
int exeIndex; // Executor index (NUMA node for CPU / device ID for GPU)
MemType srcMemType; // Source memory type
int srcIndex; // Source device index
MemType dstMemType; // Destination memory type
int dstIndex; // Destination device index
int numBlocksToUse; // Number of threadblocks to use for this Link
// Link implementation
float* srcMem; // Source memory
float* dstMem; // Destination memory
hipEvent_t startEvent;
hipEvent_t stopEvent;
hipStream_t stream;
BlockParam* blockParam;
double totalTime;
};
void DisplayUsage(char const* cmdName); // Display usage instructions
void GenerateConfigFile(char const* cfgFile, int numBlocks); // Generate a sample config file
void DisplayTopology(); // Display GPU topology
void ParseLinks(char* line, std::vector<Link>& links); // Parse Link information
void AllocateMemory(MemType memType, int devIndex, size_t numBytes, bool useFineGrainMem, float** memPtr);
void PopulateTestSizes(size_t const numBytesPerLink, int const samplingFactor, std::vector<size_t>& valuesofN);
void ParseMemType(std::string const& token, int const numCpus, int const numGpus, MemType* memType, int* memIndex);
void ParseLinks(char* line, int numCpus, int numGpus, std::vector<Link>& links); // Parse Link information
void EnablePeerAccess(int const deviceId, int const peerDeviceId);
void AllocateMemory(MemType memType, int devIndex, size_t numBytes, float** memPtr);
void DeallocateMemory(MemType memType, int devIndex, float* memPtr);
void CheckPages(char* byteArray, size_t numBytes, int targetId);
void CheckOrFill(ModeType mode, int N, bool isMemset, bool isHipCall, float* ptr);
void RunLink(EnvVars const& ev, size_t const N, int const iteration, Link& link);
std::string GetLinkTypeDesc(uint32_t linkType, uint32_t hopCount);
std::string GetDesc(MemType srcMemType, int srcIndex,
MemType dstMemType, int dstIndex);
std::string GetLinkDesc(Link const& link);
#define MAX_NAME_LEN 64
#define BLOCKSIZE 256
#define COPY_UNROLL 4
#define MEMSET_UNROLL 4
// Dummy reduction function (not used because it's just a copy)
struct FuncNull {
__device__ float operator()(const float x, const float y) const {
return 0;
}
};
// GPU copy kernel
__global__ void __launch_bounds__(BLOCKSIZE)
CopyKernel(BlockParam* blockParams)
GpuCopyKernel(BlockParam* blockParams)
{
// Collect the arguments for this block
int N = blockParams[blockIdx.x].N;
const float* __restrict__ src = (float* )blockParams[blockIdx.x].src;
float* __restrict__ dst = (float* )blockParams[blockIdx.x].dst;
// Collect the arguments for this block
int N = blockParams[blockIdx.x].N;
const float* src[1] = {(float* )blockParams[blockIdx.x].src};
float* dst[1] = {(float* )blockParams[blockIdx.x].dst};
Copy<COPY_UNROLL, BLOCKSIZE>(dst, src, N);
ReduceOrCopyMulti<COPY_UNROLL, FuncNull, float, 1, 1, 1, 1>(
threadIdx.x, BLOCKSIZE, 1, src, 1, dst, N);
}
// GPU set kernel
__global__ void __launch_bounds__(BLOCKSIZE)
MemsetKernel(BlockParam* blockParams)
GpuMemsetKernel(BlockParam* blockParams)
{
// Collect the arguments for this block
int N = blockParams[blockIdx.x].N;
float* __restrict__ dst = (float*)blockParams[blockIdx.x].dst;
// Collect the arguments for this block
int N = blockParams[blockIdx.x].N;
float* __restrict__ dst = (float*)blockParams[blockIdx.x].dst;
// Use non-zero value
#pragma unroll MEMSET_UNROLL
for (int tid = threadIdx.x; tid < N; tid += BLOCKSIZE)
{
dst[tid] = 1234.0;
}
// Use non-zero value
#pragma unroll MEMSET_UNROLL
for (int tid = threadIdx.x; tid < N; tid += BLOCKSIZE)
{
dst[tid] = 1234.0;
}
}
// CPU copy kernel
void CpuCopyKernel(BlockParam const& blockParams)
{
memcpy(blockParams.dst, blockParams.src, blockParams.N * sizeof(float));
}
// CPU memset kernel
void CpuMemsetKernel(BlockParam const& blockParams)
{
for (int i = 0; i < blockParams.N; i++)
blockParams.dst[i] = 1234.0;
}