Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/RaiderSTREAM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set (
RSSrcs
RS_Main.cpp
RSOpts.cpp
RSRes.cpp
)

if (ENABLE_OMP)
Expand Down
14 changes: 13 additions & 1 deletion src/RaiderSTREAM/Impl/RS_CUDA/RS_CUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool RS_CUDA::printCudaDeviceProps() {
*
* @return True if allocation and initialization successful, false otherwise
*/
bool RS_CUDA::allocateData() {
bool RS_CUDA::allocateData(double * allocTime, double * initTime, double * randomGenTime) {
if(cudaSetDevice(deviceId) != cudaSuccess) {
std::cout << "RS_CUDA::allocateData() - ERROR: failed setting CUDA device to "
<< deviceId
Expand All @@ -95,22 +95,28 @@ bool RS_CUDA::allocateData() {
<< std::endl;
return false;
}
double startTime;

/* Allocate host memory */
startTime = mySecond();
a = new STREAM_TYPE[streamArraySize];
b = new STREAM_TYPE[streamArraySize];
c = new STREAM_TYPE[streamArraySize];
idx1 = new ssize_t[streamArraySize];
idx2 = new ssize_t[streamArraySize];
idx3 = new ssize_t[streamArraySize];
*allocTime = calculateRunTime(startTime, mySecond());

startTime = mySecond();
for (ssize_t i = 0; i < streamArraySize; i++) {
a[i] = b[i] = c[i] = i;
}
*initTime = calculateRunTime(startTime, mySecond());

streamArrayMemSize = streamArraySize * sizeof(STREAM_TYPE);
idxArrayMemSize = streamArraySize * sizeof(ssize_t);

startTime = mySecond();
#ifdef _ARRAYGEN_
initReadIdxArray(idx1, streamArraySize, "RaiderSTREAM/arraygen/IDX1.txt");
initReadIdxArray(idx2, streamArraySize, "RaiderSTREAM/arraygen/IDX2.txt");
Expand All @@ -120,6 +126,7 @@ bool RS_CUDA::allocateData() {
initRandomIdxArray(idx2, streamArraySize);
initRandomIdxArray(idx3, streamArraySize);
#endif
*randomGenTime = calculateRunTime(startTime, mySecond());

/* a -> d_a */
if (cudaMalloc(&d_a, streamArrayMemSize) != cudaSuccess) {
Expand Down Expand Up @@ -285,6 +292,11 @@ bool RS_CUDA::allocateData() {
return true;
}


void RS_CUDA::collectChunks(double * collectTime) {
*collectTime = 0;
}

/**
* @brief Frees all allocated memory
*
Expand Down
9 changes: 8 additions & 1 deletion src/RaiderSTREAM/Impl/RS_CUDA/RS_CUDA.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ public:
* @brief Allocate memory for arrays on host and device
* @return True if successful, false otherwise
*/
virtual bool allocateData() override;
virtual bool allocateData(double * allocTime, double * initTime, double * randomGenTime) override;

/**
* @brief collect all results into one array
*
* @param collectTime The time taken to collect all results
**/
virtual void collectChunks(double *collectTime) override;

/**
* @brief Execute the benchmark kernels
Expand Down
Loading