Skip to content

Commit

Permalink
#1849: Tests: Skip CUDA test if first malloc fails
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Nov 15, 2022
1 parent 3585c4c commit 6a9bf88
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions tests/unit/active/test_async_op_cuda.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ using TestAsyncOp = TestParallelHarness;

using MyMsg = Message;

inline void checkCudaErrors(
cudaError_t err, std::string const& additionalInfo,
bool skipOnFailure = false
) {
auto errorMsg = fmt::format(
"{} failed with error -> {}\n", additionalInfo, cudaGetErrorString(err));

if (cudaSuccess != err and skipOnFailure) {
GTEST_SKIP() << errorMsg;
}

inline void checkCudaErrors(cudaError_t err, std::string const& additionalInfo) {
vtAbortIf(
cudaSuccess != err,
fmt::format(
"{} failed with error -> {}\n", additionalInfo, cudaGetErrorString(err)
)
);
vtAbortIf(cudaSuccess != err, errorMsg);
}

__global__ void kernel(double* dst, double setVal) {
Expand All @@ -79,9 +83,11 @@ struct CUDAGroup {
CUDAGroup() {
auto const nBytes = dataSize_ * sizeof(double);

// If first malloc fails, there's probably something wrong with CUDA env
// so call GTEST_SKIP instead of failing the test
checkCudaErrors(
cudaMalloc((void**)&dataDevicePointer1_, nBytes),
"cudaMalloc(dataDevicePointer1_)"
"cudaMalloc(dataDevicePointer1_)", true
);

checkCudaErrors(
Expand Down

0 comments on commit 6a9bf88

Please sign in to comment.