Skip to content

[SYCL][E2E] Add pre-C++11 ABI tests #12900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 80 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
f62375d
[SYCL][L0] return error code when ZE_DEBUG=4 detects memory leaks.
bso-intel Dec 22, 2021
7d9755e
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Dec 24, 2021
84b6710
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Dec 27, 2021
534f424
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Dec 28, 2021
81b4db5
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Dec 30, 2021
0c249f1
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 4, 2022
200f8ea
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 7, 2022
aaed454
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 11, 2022
d1c6404
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 20, 2022
1032a47
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 20, 2022
abbc3a0
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 24, 2022
1b2bcc7
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 25, 2022
4657e3b
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 28, 2022
39515bd
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 2, 2022
89e505b
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 4, 2022
6f2d5dd
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 7, 2022
f0b7ec1
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 10, 2022
0a63386
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 10, 2022
ff05096
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 14, 2022
76670e6
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 20, 2022
2228b5f
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 2, 2022
5589806
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 14, 2022
0df6354
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 18, 2022
066e537
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 21, 2022
4c6bdbf
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 28, 2022
29bfebe
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel May 31, 2022
5013125
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 1, 2022
9eeb08d
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 15, 2022
d2bfa6e
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Aug 1, 2022
ed37e84
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Aug 23, 2022
82140f2
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Aug 24, 2022
9cdb8c7
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Sep 9, 2022
e89281c
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Oct 4, 2022
df66ba6
Merge branch 'sycl' of https://github.com/bso-intel/llvm into sycl
bso-intel Oct 4, 2022
2f738d9
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Oct 25, 2022
bb0a636
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Dec 30, 2022
ef6772d
Merge branch 'sycl' of https://github.com/bso-intel/llvm into sycl
bso-intel Dec 30, 2022
af8b4d6
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 4, 2023
d53a2a8
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jan 9, 2023
c9d532e
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 14, 2023
70ceaac
merge from upstream
bso-intel Mar 7, 2023
58d75c3
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 9, 2023
002c81d
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 27, 2023
e087c5b
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 29, 2023
938b7ba
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Apr 11, 2023
958760d
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Apr 18, 2023
2fe5ece
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Apr 24, 2023
59f3656
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel May 18, 2023
434117a
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel May 22, 2023
55d41d6
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel May 25, 2023
16469df
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel May 25, 2023
f6c796b
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel May 31, 2023
d1193a3
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel May 31, 2023
7b7f84e
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 2, 2023
5739c22
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 3, 2023
1fa1d86
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 6, 2023
0ea8e1f
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 7, 2023
5319024
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 9, 2023
ace7748
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 9, 2023
b62af7f
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 12, 2023
224ce55
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 13, 2023
12e6cac
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 13, 2023
0791d2f
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 14, 2023
5d4d7d3
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 16, 2023
a7f33b7
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jun 27, 2023
4e1e4a2
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jul 6, 2023
46ce473
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jul 11, 2023
ed3c59d
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Jul 17, 2023
5250852
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Aug 9, 2023
265e6a8
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Aug 23, 2023
18d859f
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Aug 29, 2023
6630705
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Aug 30, 2023
12bdfd3
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Sep 19, 2023
98dd8a5
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Oct 26, 2023
4a13701
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Feb 20, 2024
9a641f2
Merge remote-tracking branch 'upstream/sycl' into sycl
bso-intel Mar 4, 2024
37833fd
[SYCL] ABI Neutral Tests
bso-intel Mar 5, 2024
b3a85fb
fix comment
bso-intel Mar 5, 2024
b4ad2ca
added REQUIRES
bso-intel Mar 5, 2024
85e832b
added comments
bso-intel Mar 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions sycl/test-e2e/AbiNeutral/catch-exception.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// RUN: %if preview-breaking-changes-supported %{ %{build} -fpreview-breaking-changes -D_GLIBCXX_USE_CXX11_ABI=0 -o %t2.out %}
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}
// REQUIRES: level_zero && gpu

// This test case tests if compiling works with or without
// _GLIBCXX_USE_CXX11_ABI=0.

#include <sycl/sycl.hpp>

int main() {
#ifdef _GLIBCXX_USE_CXX11_ABI
std::cout << "is_cxx11_abi: " << (_GLIBCXX_USE_CXX11_ABI != 0) << std::endl;
;
#else
std::cout << "is_cxx11_abi: 1" << std::endl;
#endif
std::vector<sycl::device> root_devices;
auto platform_list = sycl::platform::get_platforms();
// Enumerated GPU devices from GPU platform firstly.
for (const auto &platform : platform_list) {
if (platform.get_backend() != sycl::backend::ext_oneapi_level_zero) {
continue;
}
auto device_list = platform.get_devices();
for (const auto &device : device_list) {
if (device.is_gpu()) {
root_devices.push_back(device);
}
}
}
assert(root_devices.size() > 0);
std::cout << "gpu number: " << root_devices.size() << std::endl;
constexpr sycl::info::partition_property partition_by_affinity =
sycl::info::partition_property::partition_by_affinity_domain;
constexpr sycl::info::partition_affinity_domain next_partitionable =
sycl::info::partition_affinity_domain::next_partitionable;
for (const auto &root_device : root_devices) {
try {
auto sub_devices = root_device.create_sub_devices<partition_by_affinity>(
next_partitionable);
std::cout << "tile partition is supported!" << std::endl;
} catch (sycl::exception &e) {
if (e.code() != sycl::errc::feature_not_supported &&
e.code() != sycl::errc::invalid) {
throw std::runtime_error(
std::string("Failed to apply tile partition: ") + e.what());
} else {
std::cout << "tile partition is UNSUPPORTED!" << std::endl;
}
}
}
std::cout << "pass!" << std::endl;
}
149 changes: 149 additions & 0 deletions sycl/test-e2e/AbiNeutral/device-info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// RUN: %if preview-breaking-changes-supported %{ %{build} -fpreview-breaking-changes -D_GLIBCXX_USE_CXX11_ABI=0 -o %t2.out %}
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}

// This test case tests if compiling works with or without
// _GLIBCXX_USE_CXX11_ABI=0.

#include <deque>
#include <iostream>
#include <mutex>
#include <sycl/sycl.hpp>
#include <vector>

template <typename T> using dpcpp_info_t = typename T::return_type;

struct DeviceProp {
dpcpp_info_t<sycl::info::device::name> device_name;
dpcpp_info_t<sycl::info::platform::name> platform_name;
dpcpp_info_t<sycl::info::device::vendor> vendor;
dpcpp_info_t<sycl::info::device::driver_version> driver_version;
dpcpp_info_t<sycl::info::device::version> version;
dpcpp_info_t<sycl::info::device::max_compute_units> max_compute_units;
};

static std::once_flag init_device_flag;
static std::once_flag init_prop_flag;
static std::deque<std::once_flag> device_prop_flags;
static std::vector<DeviceProp> device_properties;

struct DevicePool {
std::vector<std::unique_ptr<sycl::device>> devices;
std::vector<std::unique_ptr<sycl::context>> contexts;
std::mutex mutex;
} gDevPool;

bool is_cxx11_abi() {
#ifdef _GLIBCXX_USE_CXX11_ABI
return (_GLIBCXX_USE_CXX11_ABI != 0);
#else
return true;
#endif
}

static void enumDevices(std::vector<std::unique_ptr<sycl::device>> &devices) {
auto platform_list = sycl::platform::get_platforms();
for (const auto &platform : platform_list) {
if (platform.get_backend() != sycl::backend::ext_oneapi_level_zero) {
continue;
}
auto device_list = platform.get_devices();
for (const auto &device : device_list) {
if (device.is_gpu()) {
devices.push_back(std::make_unique<sycl::device>(device));
}
}
}
}

static void initGlobalDevicePoolState() {
enumDevices(gDevPool.devices);

auto device_count = gDevPool.devices.size();
if (device_count <= 0) {
std::cout << "XPU device count is zero!" << std::endl;
return;
}
gDevPool.contexts.resize(1);
gDevPool.contexts[0] = std::make_unique<sycl::context>(
gDevPool.devices[0]->get_platform().ext_oneapi_get_default_context());
}

static void initDevicePoolCallOnce() {
std::call_once(init_device_flag, initGlobalDevicePoolState);
}

int dpcppGetDeviceCount() {
initDevicePoolCallOnce();
std::lock_guard<std::mutex> lock(gDevPool.mutex);
return static_cast<int>(gDevPool.devices.size());
}

sycl::device &dpcppGetRawDevice(int device) {
initDevicePoolCallOnce();
std::lock_guard<std::mutex> lock(gDevPool.mutex);
if (device > static_cast<int>(gDevPool.devices.size())) {
throw std::runtime_error(std::string("device is out of range"));
}
return *gDevPool.devices[device];
}

static void initDevicePropState() {
auto device_count = dpcppGetDeviceCount();
device_prop_flags.resize(device_count);
device_properties.resize(device_count);
}

static void initDeviceProperties(int device) {
DeviceProp device_prop;
auto &raw_device = dpcppGetRawDevice(device);

device_prop.device_name = raw_device.get_info<sycl::info::device::name>();
device_prop.platform_name =
raw_device.get_platform().get_info<sycl::info::platform::name>();
device_prop.vendor = raw_device.get_info<sycl::info::device::vendor>();
device_prop.driver_version =
raw_device.get_info<sycl::info::device::driver_version>();
device_prop.version = raw_device.get_info<sycl::info::device::version>();
device_prop.max_compute_units =
raw_device.get_info<sycl::info::device::max_compute_units>();

device_properties[device] = device_prop;
}

static void initDevicePropCallOnce(int device) {
std::call_once(init_prop_flag, initDevicePropState);
std::call_once(device_prop_flags[device], initDeviceProperties, device);
}

DeviceProp &dpcppGetDeviceProperties(int device) {
initDevicePropCallOnce(device);
auto device_count = dpcppGetDeviceCount();
if (device > device_count) {
throw std::runtime_error(std::string("device is out of range"));
}
return device_properties[device];
}

std::string &dpcppGetDeviceName(int device) {
return dpcppGetDeviceProperties(device).device_name;
}

int main() {
std::cout << "device_count: " << dpcppGetDeviceCount() << std::endl;
std::cout << "hello world!" << std::endl;
std::cout << "is_cxx11_abi: " << is_cxx11_abi() << std::endl;
for (auto i = 0; i < dpcppGetDeviceCount(); i++) {
// std::cout << i << "th device name is " << dpcppGetDeviceName(i) <<
// std::endl;
std::cout << i << "th device name is "
<< dpcppGetDeviceProperties(i).device_name << std::endl;
std::cout << i << "th platform name is "
<< dpcppGetDeviceProperties(i).platform_name << std::endl;
std::cout << dpcppGetDeviceProperties(i).version << std::endl;
std::cout << dpcppGetDeviceProperties(i).driver_version << std::endl;
std::cout << dpcppGetDeviceProperties(i).vendor << std::endl;
std::cout << dpcppGetDeviceProperties(i).max_compute_units << std::endl;
}
}
31 changes: 31 additions & 0 deletions sycl/test-e2e/AbiNeutral/submit-kernel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out
// RUN: %if preview-breaking-changes-supported %{ %{build} -fpreview-breaking-changes -D_GLIBCXX_USE_CXX11_ABI=0 -o %t2.out %}
// RUN: %if preview-breaking-changes-supported %{ %{run} %t2.out %}

// This test case tests if compiling works with or without
// _GLIBCXX_USE_CXX11_ABI=0.

#include <iostream>
#include <sycl/sycl.hpp>

int main() {
try {
auto cgf = [&](sycl::handler &cgh) { cgh.single_task([=]() {}); };
sycl::queue queue;
for (auto i = 0; i < 25; i++) {
sycl::malloc_device(1024, queue);
}
auto event = queue.submit(cgf);
event.wait_and_throw();
} catch (const sycl::exception &ep) {
const std::string_view err_msg(ep.what());
if (err_msg.find("PI_ERROR_OUT_OF_RESOURCES") != std::string::npos) {
std::cout << "Allocation is out of device memory on the current platform."
<< std::endl;
} else {
throw ep;
}
}
std::cout << "pass!" << std::endl;
}