Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

[SYCL][Level Zero] Add a test for sycl_ext_intel_queue_index extension #1425

Merged
merged 14 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions SYCL/Basic/subdevice_pi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ static bool check_separate(device dev, buffer<int, 1> buf,
}
// CHECK-SEPARATE: Test sub device 0
// CHECK-SEPARATE: ---> piContextCreate
// CHECK-SEPARATE: ---> piQueueCreate
// CHECK-SEPARATE: ---> piextQueueCreate
// CHECK-SEPARATE: ---> piMemBufferCreate
// CHECK-SEPARATE: ---> piEnqueueKernelLaunch
// CHECK-SEPARATE: ---> piQueueFinish
Expand All @@ -71,7 +71,7 @@ static bool check_separate(device dev, buffer<int, 1> buf,
}
// CHECK-SEPARATE: Test sub device 1
// CHECK-SEPARATE: ---> piContextCreate
// CHECK-SEPARATE: ---> piQueueCreate
// CHECK-SEPARATE: ---> piextQueueCreate
// CHECK-SEPARATE: ---> piMemBufferCreate
//
// Verify that we have a memcpy between subdevices in this case
Expand Down Expand Up @@ -107,7 +107,7 @@ static bool check_shared_context(device dev, buffer<int, 1> buf,
use_mem(buf, q0);
}
// CHECK-SHARED: Test sub device 0
// CHECK-SHARED: ---> piQueueCreate
// CHECK-SHARED: ---> piextQueueCreate
// CHECK-SHARED: ---> piMemBufferCreate
//
// Make sure that a single buffer is created (and shared between subdevices):
Expand All @@ -122,7 +122,7 @@ static bool check_shared_context(device dev, buffer<int, 1> buf,
use_mem(buf, q1);
}
// CHECK-SHARED: Test sub device 1
// CHECK-SHARED: ---> piQueueCreate
// CHECK-SHARED: ---> piextQueueCreate
// CHECK-SHARED: ---> piEnqueueKernelLaunch
// CHECK-SHARED: ---> piQueueFinish
// CHECK-SHARED: ---> piEnqueueMemBufferRead
Expand Down Expand Up @@ -156,7 +156,7 @@ static bool check_fused_context(device dev, buffer<int, 1> buf,
use_mem(buf, q);
}
// CHECK-FUSED: Test root device
// CHECK-FUSED: ---> piQueueCreate
// CHECK-FUSED: ---> piextQueueCreate
// CHECK-FUSED: ---> piMemBufferCreate
//
// Make sure that a single buffer is created (and shared between subdevices
Expand All @@ -171,7 +171,7 @@ static bool check_fused_context(device dev, buffer<int, 1> buf,
use_mem(buf, q0);
}
// CHECK-FUSED: Test sub device 0
// CHECK-FUSED: ---> piQueueCreate
// CHECK-FUSED: ---> piextQueueCreate
// CHECK-FUSED: ---> piEnqueueKernelLaunch
// CHECK-FUSED: ---> piQueueFinish

Expand All @@ -181,7 +181,7 @@ static bool check_fused_context(device dev, buffer<int, 1> buf,
use_mem(buf, q1);
}
// CHECK-FUSED: Test sub device 1
// CHECK-FUSED: ---> piQueueCreate
// CHECK-FUSED: ---> piextQueueCreate
// CHECK-FUSED: ---> piEnqueueKernelLaunch
// CHECK-FUSED: ---> piQueueFinish
// CHECK-FUSED: ---> piEnqueueMemBufferRead
Expand Down
107 changes: 107 additions & 0 deletions SYCL/Plugin/level_zero_ext_intel_queue_index.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %level_zero_options %s -o %t.out
// RUN: env ZEX_NUMBER_OF_CCS=0:4 env ZE_DEBUG=1 %GPU_RUN_PLACEHOLDER %t.out > %t.log 2>&1
// RUN: %GPU_RUN_PLACEHOLDER FileCheck %s --check-prefixes=CHECK-PVC < %t.log
//
// Same with Immediate CommandLists
// RUN: env SYCL_PI_LEVEL_ZERO_EXPOSE_CSLICE_IN_AFFINITY_PARTITIONING=1 env ZEX_NUMBER_OF_CCS=0:4 env ZE_DEBUG=1 %GPU_RUN_PLACEHOLDER %t.out > %t.log 2>&1
// RUN: %GPU_RUN_PLACEHOLDER FileCheck %s --check-prefixes=CHECK-PVC < %t.log

// Requires: level_zero

#include <sycl/sycl.hpp>

using namespace sycl;

void test_pvc(device &d) {
std::cout << "Test PVC Begin" << std::endl;
// CHECK-PVC: Test PVC Begin
bool IsPVC = [&]() {
if (!d.has(aspect::ext_intel_device_id))
return false;
return (d.get_info<ext::intel::info::device::device_id>() & 0xff0) == 0xbd0;
}();
std::cout << "IsPVC: " << std::boolalpha << IsPVC << std::endl;
if (IsPVC) {
assert(d.get_info<ext::intel::info::device::max_compute_queue_indices>() ==
1);

auto sub_devices = d.create_sub_devices<
info::partition_property::partition_by_affinity_domain>(
info::partition_affinity_domain::next_partitionable);
device &sub_device = sub_devices[1];
assert(
sub_device
.get_info<ext::intel::info::device::max_compute_queue_indices>() ==
4);

auto sub_sub_devices = sub_device.create_sub_devices<
info::partition_property::ext_intel_partition_by_cslice>();
device &sub_sub_device = sub_sub_devices[1];
assert(
sub_sub_device
.get_info<ext::intel::info::device::max_compute_queue_indices>() ==
1);

{
bool ExceptionThrown = false;
try {
std::ignore = queue{d, ext::intel::property::queue::compute_index{-1}};

} catch (...) {
ExceptionThrown = true;
}
assert(ExceptionThrown);
}
{
bool ExceptionThrown = false;
try {
std::ignore = queue{sub_sub_device,
ext::intel::property::queue::compute_index{1}};

} catch (...) {
ExceptionThrown = true;
}
assert(ExceptionThrown);
}

{
queue q{sub_device};
// CHECK-PVC: [getZeQueue]: create queue ordinal = 0, index = 0 (round robin in [0, 0])
q.single_task([=]() {}).wait();
}
{
queue q{sub_device, ext::intel::property::queue::compute_index{2}};
// CHECK-PVC: [getZeQueue]: create queue ordinal = 0, index = 2 (round robin in [2, 2])
q.single_task([=]() {}).wait();
}
{
queue q{sub_device, ext::intel::property::queue::compute_index{2}};
// CHECK-PVC: [getZeQueue]: create queue ordinal = 0, index = 2 (round robin in [2, 2])
q.single_task([=]() {}).wait();
}
{
queue q{sub_sub_device};
// CHECK-PVC: [getZeQueue]: create queue ordinal = 0, index = 1 (round robin in [1, 1])
q.single_task([=]() {}).wait();
}
} else {
// Make FileCheck pass.
std::cout << "Fake ZE_DEBUG output for FileCheck:" << std::endl;
// clang-format off
std::cout << "[getZeQueue]: create queue ordinal = 0, index = 0 (round robin in [0, 0])" << std::endl;
std::cout << "[getZeQueue]: create queue ordinal = 0, index = 2 (round robin in [2, 2])" << std::endl;
std::cout << "[getZeQueue]: create queue ordinal = 0, index = 2 (round robin in [2, 2])" << std::endl;
std::cout << "[getZeQueue]: create queue ordinal = 0, index = 1 (round robin in [1, 1])" << std::endl;
// clang-format on
}
std::cout << "Test PVC End" << std::endl;
// CHECK-PVC: Test PVC End
}

int main() {
device d;

test_pvc(d);

return 0;
}
2 changes: 1 addition & 1 deletion SYCL/Scheduler/ReleaseResourcesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int main() {
}

// CHECK:---> piContextCreate
// CHECK:---> piQueueCreate
// CHECK:---> piextQueueCreate
// CHECK:---> piProgramCreate
// CHECK:---> piKernelCreate
// CHECK:---> piQueueRelease
Expand Down