Skip to content

Commit

Permalink
Some GPU testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
BrendanKKrueger committed Aug 28, 2024
1 parent b1f21fe commit cd5c492
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test_array.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
#include "ports-of-call/array.hpp"
#include "ports-of-call/portability.hpp"

#include <iostream>

using namespace PortsOfCall;

TEST_CASE("array nominal element access (GPU)", "[array][GPU]") {
// Declare the array
constexpr int N = 16;
array<double, N> arr;

int count = 0;
auto func = PORTABLE_LAMBDA(const int i, int & count) {
// Fill the array
arr[i] = i + 1;
// Can we read from it?
if (arr[i] = i + 1) {
++count;
}
};
PortsOfCall::parallelReduce("assign_and_check", 0, N, func, count);
CHECK(count == N);
}

TEST_CASE("array nominal element access", "[array]") {
// Declare the array
constexpr int N = 16;
Expand Down Expand Up @@ -176,6 +195,22 @@ TEST_CASE("array sizes", "[array]") {
CHECK(arr.size() == arr.max_size());
}

TEST_CASE("array fill (GPU)", "[array][GPU]") {
constexpr std::size_t N = 42;
std::size_t count = 0;
auto func = PORTABLE_LAMBDA(const int i, int & count) {
constexpr double value = 3.14;
array<double, N> arr;
arr.fill(value);
for (const double x : arr) {
count += (x == value) ? 1 : 0;
}
};
constexpr std::size_t M = 5;
PortsOfCall::parallelReduce("check", 0, M, func, count);
CHECK(count == N * M);
}

TEST_CASE("array fill", "[array]") {
array<double, 42> arr;
arr.fill(3.14);
Expand Down

0 comments on commit cd5c492

Please sign in to comment.