1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <catch.hpp>
#include "DataFormats/Portable/interface/PortableObject.h"
#include "DataFormats/Portable/interface/PortableHostObject.h"
namespace {
struct Test {
int a;
float b;
};
constexpr auto s_tag = "[PortableObject]";
} // namespace
// This test is currently mostly about the code compiling
TEST_CASE("Use of PortableObject<T> on host code", s_tag) {
static_assert(std::is_same_v<PortableObject<Test, alpaka::DevCpu>, PortableHostObject<Test>>);
SECTION("Initialize by setting members") {
SECTION("With device") {
PortableObject<Test, alpaka::DevCpu> obj(cms::alpakatools::host());
obj->a = 42;
REQUIRE(obj->a == 42);
}
SECTION("With queue") {
alpaka::QueueCpuBlocking queue(cms::alpakatools::host());
PortableObject<Test, alpaka::DevCpu> obj(queue);
obj->a = 42;
REQUIRE(obj->a == 42);
}
}
SECTION("Initialize via constructor") {
SECTION("With device") {
PortableObject<Test, alpaka::DevCpu> obj(cms::alpakatools::host(), Test{42, 3.14f});
REQUIRE(obj->a == 42);
REQUIRE(obj->b == 3.14f);
}
SECTION("With queue") {
alpaka::QueueCpuBlocking queue(cms::alpakatools::host());
PortableObject<Test, alpaka::DevCpu> obj(queue, Test{42, 3.14f});
REQUIRE(obj->a == 42);
REQUIRE(obj->b == 3.14f);
}
}
}
|