| 1 |
//@HEADER |
| 2 |
// ************************************************************************ |
| 3 |
// |
| 4 |
// Kokkos v. 4.0 |
| 5 |
// Copyright (2022) National Technology & Engineering |
| 6 |
// Solutions of Sandia, LLC (NTESS). |
| 7 |
// |
| 8 |
// Under the terms of Contract DE-NA0003525 with NTESS, |
| 9 |
// the U.S. Government retains certain rights in this software. |
| 10 |
// |
| 11 |
// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. |
| 12 |
// See https://kokkos.org/LICENSE for license information. |
| 13 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 14 |
// |
| 15 |
//@HEADER |
| 16 |
|
| 17 |
#include <TestSYCL_Category.hpp> |
| 18 |
#include <TestMultiGPU.hpp> |
| 19 |
|
| 20 |
namespace { |
| 21 |
|
| 22 |
std::array<TEST_EXECSPACE, 2> get_execution_spaces() { |
| 23 |
std::vector<sycl::device> gpu_devices = |
| 24 |
sycl::device::get_devices(sycl::info::device_type::gpu); |
| 25 |
|
| 26 |
TEST_EXECSPACE exec0( |
| 27 |
sycl::queue{gpu_devices.front(), sycl::property::queue::in_order()}); |
| 28 |
TEST_EXECSPACE exec1( |
| 29 |
sycl::queue{gpu_devices.back(), sycl::property::queue::in_order()}); |
| 30 |
|
| 31 |
return {exec0, exec1}; |
| 32 |
} |
| 33 |
|
| 34 |
TEST(sycl_multi_gpu, managed_views) { |
| 35 |
std::array<TEST_EXECSPACE, 2> execs = get_execution_spaces(); |
| 36 |
|
| 37 |
Kokkos::View<int *, TEST_EXECSPACE> view0(Kokkos::view_alloc("v0", execs[0]), |
| 38 |
100); |
| 39 |
Kokkos::View<int *, TEST_EXECSPACE> view(Kokkos::view_alloc("v", execs[1]), |
| 40 |
100); |
| 41 |
|
| 42 |
test_policies(execs[0], view0, execs[1], view); |
| 43 |
} |
| 44 |
|
| 45 |
TEST(sycl_multi_gpu, unmanaged_views) { |
| 46 |
std::array<TEST_EXECSPACE, 2> execs = get_execution_spaces(); |
| 47 |
|
| 48 |
int *p0 = sycl::malloc_device<int>(100, execs[0].sycl_queue()); |
| 49 |
Kokkos::View<int *, TEST_EXECSPACE> view0(p0, 100); |
| 50 |
|
| 51 |
int *p1 = sycl::malloc_device<int>(100, execs[1].sycl_queue()); |
| 52 |
Kokkos::View<int *, TEST_EXECSPACE> view1(p1, 100); |
| 53 |
|
| 54 |
test_policies(execs[0], view0, execs[1], view1); |
| 55 |
sycl::free(p0, execs[0].sycl_queue()); |
| 56 |
sycl::free(p1, execs[1].sycl_queue()); |
| 57 |
} |
| 58 |
|
| 59 |
TEST(sycl_multi_gpu, scratch_space) { |
| 60 |
std::array<TEST_EXECSPACE, 2> execs = get_execution_spaces(); |
| 61 |
|
| 62 |
test_scratch(execs[0], execs[1]); |
| 63 |
} |
| 64 |
} // namespace |