Skip to content

[SYCL][E2E] Added SYCL aspect for freememory #8844

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 5 commits into from
Mar 29, 2023
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
50 changes: 12 additions & 38 deletions sycl/test-e2e/Basic/intel-ext-device.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// RUN: %clangxx -fsycl %s -o %t.out
// RUN: env ONEAPI_DEVICE_SELECTOR=level_zero:gpu %t.out
// RUN: env ONEAPI_DEVICE_SELECTOR=opencl:gpu %t.out
// REQUIRES: level_zero || opencl
// RUN: %GPU_RUN_PLACEHOLDER %t.out
//
// REQUIRES: gpu
// UNSUPPORTED: hip
// Temporarily disable on L0 due to fails in CI

//==--------- intel-ext-device.cpp - SYCL device test ------------==//
//
// Returns the low-level device details. These are Intel-specific extensions
// that are only supported on Level Zero.
// that are only supported on Level Zero or OpenCL.
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down Expand Up @@ -51,6 +47,8 @@ int main(int argc, char **argv) {
std::cout << "Backend: ";
if (plt.get_backend() == backend::ext_oneapi_level_zero) {
std::cout << "Level Zero" << std::endl;
// It's required to set the env variable to query free-memory.
setenv("ZES_ENABLE_SYSMAN", "1", 0);
} else if (plt.get_backend() == backend::opencl) {
std::cout << "OpenCL" << std::endl;
} else if (plt.get_backend() == backend::ext_oneapi_cuda) {
Expand Down Expand Up @@ -110,6 +108,13 @@ int main(int argc, char **argv) {
std::cout << "Failed!" << std::endl;
return 1;
}
if (dev.has(aspect::ext_intel_free_memory)) {
auto TotalMemory = dev.get_info<info::device::global_mem_size>();
auto FreeMemory =
dev.get_info<ext::intel::info::device::free_memory>();
assert((TotalMemory >= FreeMemory) &&
"Expect total_memory >= free_memory");
}
if (SYCL_EXT_INTEL_DEVICE_INFO >= 2 &&
dev.has(aspect::ext_intel_device_info_uuid)) {
auto UUID = dev.get_info<ext::intel::info::device::uuid>();
Expand All @@ -126,37 +131,6 @@ int main(int argc, char **argv) {
}
} // SYCL_EXT_INTEL_DEVICE_INFO
}

// Check if this experimental feature is supported
#ifdef SYCL_EXT_ONEAPI_MAX_WORK_GROUP_QUERY
sycl::id<1> groupD = dev.get_info<
sycl::ext::oneapi::experimental::info::device::max_work_groups<1>>();
std::cout << "Max work group size in 1D \n";
std::cout << "Dimension 1:" << groupD[0] << std::endl;

sycl::id<2> group2D = dev.get_info<
sycl::ext::oneapi::experimental::info::device::max_work_groups<2>>();
std::cout << "Max work group size in 2D \n";
std::cout << "Dimension 1:" << group2D[0] << "\n"
<< "Dimension 2:" << group2D[1] << std::endl;

sycl::id<3> group3D = dev.get_info<
sycl::ext::oneapi::experimental::info::device::max_work_groups<3>>();
std::cout << "Max work group size in 3D \n";
std::cout << "Dimension 1:" << group3D[0] << "\n"
<< "Dimension 2:" << group3D[1] << "\n"
<< "Dimension 3:" << group3D[2] << std::endl;

size_t group_max = dev.get_info<sycl::ext::oneapi::experimental::info::
device::max_global_work_groups>();
std::cout << "Max global work group size:" << group_max << "\n";

assert((group3D[0] <= group_max && group3D[1] <= group_max &&
group3D[2] <= group_max) &&
"Max work-group size of each dimension must be smaller than "
"global work-group size");
#endif

std::cout << std::endl;
}
}
Expand Down
49 changes: 49 additions & 0 deletions sycl/test-e2e/Basic/max_work_group_query.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// REQUIRES: cuda || hip || level_zero
// RUN: %GPU_RUN_PLACEHOLDER %t.out

#include <sycl/sycl.hpp>

#include <cassert>
#include <iostream>

using namespace sycl;

int main() {
queue q;
device dev = q.get_device();

#if !defined(SYCL_EXT_ONEAPI_MAX_WORK_GROUP_QUERY)
#error SYCL_EXT_ONEAPI_MAX_WORK_GROUP_QUERY is not defined!
#endif

sycl::id<1> groupD = dev.get_info<
sycl::ext::oneapi::experimental::info::device::max_work_groups<1>>();
std::cout << "Max work group size in 1D \n";
std::cout << "Dimension 1:" << groupD[0] << std::endl;

sycl::id<2> group2D = dev.get_info<
sycl::ext::oneapi::experimental::info::device::max_work_groups<2>>();
std::cout << "Max work group size in 2D \n";
std::cout << "Dimension 1:" << group2D[0] << "\n"
<< "Dimension 2:" << group2D[1] << std::endl;

sycl::id<3> group3D = dev.get_info<
sycl::ext::oneapi::experimental::info::device::max_work_groups<3>>();
std::cout << "Max work group size in 3D \n";
std::cout << "Dimension 1:" << group3D[0] << "\n"
<< "Dimension 2:" << group3D[1] << "\n"
<< "Dimension 3:" << group3D[2] << std::endl;

size_t group_max = dev.get_info<
sycl::ext::oneapi::experimental::info::device::max_global_work_groups>();
std::cout << "Max global work group size:" << group_max << "\n";

assert((group3D[0] <= group_max && group3D[1] <= group_max &&
group3D[2] <= group_max) &&
"Max work-group size of each dimension must be smaller than "
"global work-group size");

std::cout << "Passed!" << std::endl;
return 0;
}