From cd5c4927613cb7c032d3f3a3de931657cbf2303b Mon Sep 17 00:00:00 2001 From: "Brendan K. Krueger" Date: Wed, 28 Aug 2024 15:55:43 -0600 Subject: [PATCH] Some GPU testing. --- test/test_array.hpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/test_array.hpp b/test/test_array.hpp index 3fa50e39..39615547 100644 --- a/test/test_array.hpp +++ b/test/test_array.hpp @@ -1,9 +1,28 @@ #include "ports-of-call/array.hpp" +#include "ports-of-call/portability.hpp" #include using namespace PortsOfCall; +TEST_CASE("array nominal element access (GPU)", "[array][GPU]") { + // Declare the array + constexpr int N = 16; + array 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; @@ -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 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 arr; arr.fill(3.14);