Skip to content

Commit

Permalink
Fix atlas_test_array compiled with GPU support but run without GPU de…
Browse files Browse the repository at this point in the history
…vices available
  • Loading branch information
wdeconinck committed Sep 17, 2024
1 parent bf71640 commit 44850d9
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/tests/array/test_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "atlas/array/gridtools/GridToolsMakeView.h"
#endif

#include "hic/hic.h"

using namespace atlas::array;

namespace atlas {
Expand Down Expand Up @@ -553,11 +555,29 @@ CASE("test_wrap") {
EXPECT(view(2) == 19);
}

static int devices() {
static int devices_ = [](){
int n = 0;
auto err = hicGetDeviceCount(&n);
if (err != hicSuccess) {
n = 0;
hicGetLastError();
}
return n;
}();
return devices_;
}

CASE("test_acc_map") {
Array* ds = Array::create<double>(2, 3, 4);
EXPECT_NO_THROW(ds->allocateDevice());
EXPECT_NO_THROW(ds->accMap());
EXPECT(ds->accMapped() == ATLAS_HAVE_ACC);
if( ds->deviceAllocated() ) {
EXPECT_NO_THROW(ds->accMap());
EXPECT_EQ(ds->accMapped(), std::min(devices(),1));
}
else {
Log::warning() << "WARNING: Array could not be allocated on device, so acc_map could not be tested" << std::endl;
}
delete ds;
}

Expand Down

0 comments on commit 44850d9

Please sign in to comment.