Skip to content
Closed
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ std::string platformInfoToString(pi_platform_info info);
template <class To, class From> To cast(From value);

// Holds the PluginInformation for the plugin that is bound.
// Currently a global varaible is used to store OpenCL plugin information to be
// Currently a global variable is used to store OpenCL plugin information to be
// used with SYCL Interoperability Constructors.
extern std::shared_ptr<plugin> GlobalPlugin;

Expand Down
3 changes: 2 additions & 1 deletion sycl/plugins/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ message(STATUS "Including the PI API CUDA backend.")

find_package(CUDA 10.0 REQUIRED)

add_library(cudadrv SHARED IMPORTED)
# Make imported library global to use it within the project.
add_library(cudadrv SHARED IMPORTED GLOBAL)

set_target_properties(
cudadrv PROPERTIES
Expand Down
10 changes: 9 additions & 1 deletion sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name,
pi_uint64{max_alloc});
}
case PI_DEVICE_INFO_IMAGE_SUPPORT: {
return getInfo(param_value_size, param_value, param_value_size_ret, false);
return getInfo(param_value_size, param_value, param_value_size_ret,
PI_FALSE);
}
case PI_DEVICE_INFO_MAX_READ_IMAGE_ARGS: {
return getInfo(param_value_size, param_value, param_value_size_ret, 0);
Expand Down Expand Up @@ -2783,6 +2784,11 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
// PI interface supports higher version or the same version.
strncpy(PluginInit->PluginVersion, SupportedVersion, 4);

// Set whole function table to zero to make it easier to detect if
// functions are not set up below.
std::memset(&(PluginInit->PiFunctionTable), 0,
sizeof(PluginInit->PiFunctionTable));

// Forward calls to OpenCL RT.
#define _PI_CL(pi_api, cuda_api) \
(PluginInit->PiFunctionTable).pi_api = (decltype(&::pi_api))(&cuda_api);
Expand Down Expand Up @@ -2837,6 +2843,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
_PI_CL(piKernelRetain, cuda_piKernelRetain)
_PI_CL(piKernelRelease, cuda_piKernelRelease)
_PI_CL(piKernelSetExecInfo, cuda_piKernelSetExecInfo)

// Event
_PI_CL(piEventCreate, cuda_piEventCreate)
_PI_CL(piEventGetInfo, cuda_piEventGetInfo)
Expand Down Expand Up @@ -2868,6 +2875,7 @@ pi_result piPluginInit(pi_plugin *PluginInit) {
_PI_CL(piEnqueueMemImageFill, cuda_piEnqueueMemImageFill)
_PI_CL(piEnqueueMemBufferMap, cuda_piEnqueueMemBufferMap)
_PI_CL(piEnqueueMemUnmap, cuda_piEnqueueMemUnmap)

_PI_CL(piextKernelSetArgMemObj, cuda_piextKernelSetArgMemObj)

#undef _PI_CL
Expand Down
5 changes: 3 additions & 2 deletions sycl/test/aot/accelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down Expand Up @@ -67,12 +68,12 @@ int main() {
simple_vadd(D, E, F);
for (unsigned int i = 0; i < array_size; i++) {
if (C[i] != A[i] + B[i]) {
std::cout << "The results are incorrect (element " << i << " is " << C[i]
std::cerr << "The results are incorrect (element " << i << " is " << C[i]
<< "!\n";
return 1;
}
if (F[i] != D[i] + E[i]) {
std::cout << "The results are incorrect (element " << i << " is " << F[i]
std::cerr << "The results are incorrect (element " << i << " is " << F[i]
<< "!\n";
return 1;
}
Expand Down
5 changes: 3 additions & 2 deletions sycl/test/aot/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down Expand Up @@ -67,12 +68,12 @@ int main() {
simple_vadd(D, E, F);
for (unsigned int i = 0; i < array_size; i++) {
if (C[i] != A[i] + B[i]) {
std::cout << "The results are incorrect (element " << i << " is " << C[i]
std::cerr << "The results are incorrect (element " << i << " is " << C[i]
<< "!\n";
return 1;
}
if (F[i] != D[i] + E[i]) {
std::cout << "The results are incorrect (element " << i << " is " << F[i]
std::cerr << "The results are incorrect (element " << i << " is " << F[i]
<< "!\n";
return 1;
}
Expand Down
9 changes: 6 additions & 3 deletions sycl/test/aot/gpu.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// REQUIRES: ocloc, gpu
// UNSUPPORTED: cuda
// CUDA is not compatible with SPIR.

// RUN: %clangxx -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend=spir64_gen-unknown-unknown-sycldevice "-device skl" %s -o %t.out
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// XFAIL: cuda

//==----- gpu.cpp - AOT compilation for gen devices using GEN compiler ------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
Expand Down Expand Up @@ -36,6 +38,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down Expand Up @@ -67,12 +70,12 @@ int main() {
simple_vadd(D, E, F);
for (unsigned int i = 0; i < array_size; i++) {
if (C[i] != A[i] + B[i]) {
std::cout << "The results are incorrect (element " << i << " is " << C[i]
std::cerr << "The results are incorrect (element " << i << " is " << C[i]
<< "!\n";
return 1;
}
if (F[i] != D[i] + E[i]) {
std::cout << "The results are incorrect (element " << i << " is " << F[i]
std::cerr << "The results are incorrect (element " << i << " is " << F[i]
<< "!\n";
return 1;
}
Expand Down
7 changes: 5 additions & 2 deletions sycl/test/aot/multiple-devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//===------------------------------------------------------------------------===//

// REQUIRES: opencl-aot, ocloc, aoc, cpu, gpu, accelerator
// UNSUPPORTED: cuda
// CUDA is not compatible with SPIR.

// 1-command compilation case
// Targeting CPU, GPU, FPGA
Expand Down Expand Up @@ -88,6 +90,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down Expand Up @@ -119,12 +122,12 @@ int main() {
simple_vadd(D, E, F);
for (unsigned int i = 0; i < array_size; i++) {
if (C[i] != A[i] + B[i]) {
std::cout << "The results are incorrect (element " << i << " is " << C[i]
std::cerr << "The results are incorrect (element " << i << " is " << C[i]
<< "!\n";
return 1;
}
if (F[i] != D[i] + E[i]) {
std::cout << "The results are incorrect (element " << i << " is " << F[i]
std::cerr << "The results are incorrect (element " << i << " is " << F[i]
<< "!\n";
return 1;
}
Expand Down
5 changes: 3 additions & 2 deletions sycl/test/aot/with-llvm-bc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ void simple_vadd(const std::array<T, N>& VA, const std::array<T, N>& VB,
std::cerr << "Unknown async exception was caught." << std::endl;
}
}
throw "ERROR: Asynchronous exception(s)";
});

cl::sycl::range<1> numOfItems{N};
Expand Down Expand Up @@ -71,12 +72,12 @@ int main() {
simple_vadd(D, E, F);
for (unsigned int i = 0; i < array_size; i++) {
if (C[i] != A[i] + B[i]) {
std::cout << "The results are incorrect (element " << i << " is " << C[i]
std::cerr << "The results are incorrect (element " << i << " is " << C[i]
<< "!\n";
return 1;
}
if (F[i] != D[i] + E[i]) {
std::cout << "The results are incorrect (element " << i << " is " << F[i]
std::cerr << "The results are incorrect (element " << i << " is " << F[i]
<< "!\n";
return 1;
}
Expand Down
74 changes: 37 additions & 37 deletions sycl/test/basic_tests/accessor/accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "../../helpers.hpp"
#include <CL/sycl.hpp>
#include <cassert>

namespace sycl {
using namespace cl::sycl;
Expand Down Expand Up @@ -77,19 +77,19 @@ int main() {
auto acc_src = buf_src.get_access<sycl::access::mode::read>();
auto acc_dst = buf_dst.get_access<sycl::access::mode::read_write>();

assert(!acc_src.is_placeholder());
assert(acc_src.get_size() == sizeof(src));
assert(acc_src.get_count() == 2);
assert(acc_src.get_range() == sycl::range<1>(2));
CHECK(!acc_src.is_placeholder());
CHECK(acc_src.get_size() == sizeof(src));
CHECK(acc_src.get_count() == 2);
CHECK(acc_src.get_range() == sycl::range<1>(2));

// Make sure that operator[] is defined for both size_t and id<1>.
// Implicit conversion from IdxSzT to size_t guarantees that no
// implicit conversion from size_t to id<1> will happen.
assert(acc_src[IdxSzT(0)] + acc_src[IdxID1(1)] == 10);
CHECK(acc_src[IdxSzT(0)] + acc_src[IdxID1(1)] == 10);

acc_dst[0] = acc_src[0] + acc_src[IdxID1(0)];
acc_dst[id1] = acc_src[1] + acc_src[IdxSzT(1)];
assert(dst[0] == 6 && dst[1] == 14);
CHECK(dst[0] == 6 && dst[1] == 14);
}

// Three-dimensional host accessor.
Expand All @@ -101,18 +101,18 @@ int main() {
sycl::buffer<int, 3> buf(data, sycl::range<3>(2, 3, 4));
auto acc = buf.get_access<sycl::access::mode::read_write>();

assert(!acc.is_placeholder());
assert(acc.get_size() == sizeof(data));
assert(acc.get_count() == 24);
assert(acc.get_range() == sycl::range<3>(2, 3, 4));
CHECK(!acc.is_placeholder());
CHECK(acc.get_size() == sizeof(data));
CHECK(acc.get_count() == 24);
CHECK(acc.get_range() == sycl::range<3>(2, 3, 4));

for (int i = 0; i < 2; ++i)
for (int j = 0; j < 3; ++j)
for (int k = 0; k < 4; ++k)
acc[IdxID3(i, j, k)] += acc[sycl::id<3>(i, j, k)];
}
for (int i = 0; i < 24; ++i) {
assert(data[i] == 2 * i);
CHECK(data[i] == 2 * i);
}
}
int data = 5;
Expand All @@ -125,16 +125,16 @@ int main() {

Queue.submit([&](sycl::handler &cgh) {
auto acc = buf.get_access<sycl::access::mode::read_write>(cgh);
assert(!acc.is_placeholder());
assert(acc.get_size() == sizeof(int));
assert(acc.get_count() == 1);
assert(acc.get_range() == sycl::range<1>(1));
CHECK(!acc.is_placeholder());
CHECK(acc.get_size() == sizeof(int));
CHECK(acc.get_count() == 1);
CHECK(acc.get_range() == sycl::range<1>(1));
cgh.single_task<class kernel>(
[=]() { acc[IdxSzT(0)] += acc[IdxID1(0)]; });
});
Queue.wait();
}
assert(data == 10);
CHECK(data == 10);

// Device accessor with 2-dimensional subscript operators.
{
Expand All @@ -158,7 +158,7 @@ int main() {
for (int j = 0; j < 3; j++) {
std::cout << "array[" << i << "][" << j << "]=" << array[i][j]
<< std::endl;
assert(array[i][j] == i * 3 + j);
CHECK(array[i][j] == i * 3 + j);
}
}
}
Expand Down Expand Up @@ -188,7 +188,7 @@ int main() {
for (int k = 0; k < 4; k++) {
std::cout << "array[" << i << "][" << j << "][" << k
<< "]=" << array[i][j][k] << std::endl;
assert(array[i][j][k] == k + 4 * (j + 3 * i));
CHECK(array[i][j][k] == k + 4 * (j + 3 * i));
}
}
}
Expand All @@ -211,11 +211,11 @@ int main() {

auto host_acc = buf.get_access<sycl::access::mode::read>();
for (int i = 0; i != 3; ++i)
assert(host_acc[i] == 42);
CHECK(host_acc[i] == 42);

} catch (cl::sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
std::cerr << "SYCL exception caught: " << e.what();
throw;
}
}

Expand All @@ -236,8 +236,8 @@ int main() {
auto host_acc =
buf.get_access<sycl::access::mode::discard_read_write>();
} catch (cl::sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
std::cerr << "SYCL exception caught: " << e.what();
throw;
}
}

Expand All @@ -262,7 +262,7 @@ int main() {
}
for (int i = 0; i < 10; i++) {
std::cout << "array[" << i << "]=" << array[i] << std::endl;
assert(array[i] == 333);
CHECK(array[i] == 333);
}
}
}
Expand Down Expand Up @@ -296,8 +296,8 @@ int main() {
for (int i = 0; i < 10; i++) {
std::cout << "array1[" << i << "]=" << array1[i] << std::endl;
std::cout << "array2[" << i << "]=" << array2[i] << std::endl;
assert(array1[i] == 333);
assert(array2[i] == 666);
CHECK(array1[i] == 333);
CHECK(array2[i] == 666);
}
}
}
Expand Down Expand Up @@ -326,7 +326,7 @@ int main() {
}
for (int i = 0; i < 10; i++) {
std::cout << "array[" << i << "]=" << array[i] << std::endl;
assert(array[i] == 333);
CHECK(array[i] == 333);
}
}
}
Expand All @@ -349,11 +349,11 @@ int main() {

auto host_acc = buf.get_access<sycl::access::mode::read>();
for (int i = 0; i != 3; ++i)
assert(host_acc[i] == 42);
CHECK(host_acc[i] == 42);

} catch (cl::sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
std::cerr << "SYCL exception caught: " << e.what();
throw;
}
}

Expand All @@ -374,10 +374,10 @@ int main() {
});
});
}
assert(data == 399);
CHECK(data == 399);
} catch (sycl::exception e) {
std::cout << "SYCL exception caught: " << e.what();
return 1;
std::cerr << "SYCL exception caught: " << e.what();
throw;
}
}

Expand Down Expand Up @@ -424,8 +424,8 @@ int main() {
sycl::access::target::host_buffer>
acc6(buf3, sycl::range<1>(1));

assert(acc4 == 2);
assert(acc5[0] == 4);
assert(acc6[0] == 6);
CHECK(acc4 == 2);
CHECK(acc5[0] == 4);
CHECK(acc6[0] == 6);
}
}
Loading