Skip to content

Commit

Permalink
Merge branch 'develop' into release/2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbeckingsale committed Sep 2, 2020
2 parents 7afa241 + a7c28f8 commit 1d3aa0a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ int main(int CHAI_UNUSED_ARG(argc), char** CHAI_UNUSED_ARG(argv))
forall(gpu(), 0, 10, [=] __device__(int i) { v2[i] *= 2.0f; });

std::cout << "Casting v2 to a pointer." << std::endl;
#if defined(CHAI_ENABLE_IMPLICIT_CONVERSIONS)
float* raw_v2 = v2;
#else
float* raw_v2 = v2.data();
#endif

std::cout << "raw_v2 = [";
for (int i = 0; i < 10; i++) {
Expand All @@ -100,7 +104,11 @@ int main(int CHAI_UNUSED_ARG(argc), char** CHAI_UNUSED_ARG(argv))
std::cout << " ]" << std::endl;

std::cout << "Casting device_array to a pointer." << std::endl;
#if defined(CHAI_ENABLE_IMPLICIT_CONVERSIONS)
int* raw_device_array = device_array;
#else
int* raw_device_array = device_array.data();
#endif
std::cout << "device_array = [";
for (int i = 0; i < 10; i++) {
std::cout << " " << device_array[i];
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/managed_array_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,11 @@ TEST(ManagedArray, ExternalOwnedFromManagedArray)
chai::ManagedArray<float> arrayCopy =
chai::makeManagedArray<float>(array.getPointer(chai::CPU), 20, chai::CPU, true);

#if defined(CHAI_ENABLE_IMPLICIT_CONVERSIONS)
ASSERT_EQ(array, arrayCopy);
#else
ASSERT_EQ(array.data(), arrayCopy.data());
#endif
// should be able to free through the new ManagedArray
arrayCopy.free();
assert_empty_map(true);
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/managed_ptr_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,11 @@ GPU_TEST(managed_ptr, gpu_class_with_raw_array_and_callback)
array[i] = expectedValue;
});

#if defined(CHAI_ENABLE_IMPLICIT_CONVERSIONS)
auto cpuPointer = new RawArrayClass(array);
#else
auto cpuPointer = new RawArrayClass(array.data());
#endif
auto gpuPointer = chai::detail::make_on_device<RawArrayClass>(array);

auto callback = [=] (chai::Action action, chai::ExecutionSpace space, void*) mutable -> bool {
Expand Down

0 comments on commit 1d3aa0a

Please sign in to comment.