Skip to content

[SYCL][NFC] Adjust names of some PI utilities. #524

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 1 commit into from
Aug 19, 2019
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
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class buffer {

size_t BufSize = 0;
PI_CALL(detail::RT::piMemGetInfo(
detail::pi::pi_cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE,
detail::pi::cast<detail::RT::PiMem>(MemObject), CL_MEM_SIZE,
sizeof(size_t), &BufSize, nullptr));

Range[0] = BufSize / sizeof(T);
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/clusm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ inline cl::sycl::detail::usm::CLUSM *GetCLUSM() {
}

cl::sycl::detail::usm::CLUSM *retVal = nullptr;
if (cl::sycl::detail::pi::piUseBackend(
cl::sycl::detail::pi::PiBackend::SYCL_BE_PI_OPENCL)) {
if (cl::sycl::detail::pi::useBackend(
cl::sycl::detail::pi::Backend::SYCL_BE_PI_OPENCL)) {
retVal = gCLUSM;
}
return retVal;
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/context_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ template <info::context param> struct get_context_info {
static RetType _(RT::PiContext ctx) {
RetType Result = 0;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piContextGetInfo(ctx, pi::pi_cast<pi_context_info>(param),
PI_CALL(RT::piContextGetInfo(ctx, pi::cast<pi_context_info>(param),
sizeof(Result), &Result, nullptr));
return Result;
}
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/device_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class device_impl_pi : public device_impl {
PI_CALL(RT::piDeviceRetain(m_device));
}
// TODO: check that device is an OpenCL interop one
return pi::pi_cast<cl_device_id>(m_device);
return pi::cast<cl_device_id>(m_device);
}

RT::PiDevice &getHandleRef() override { return m_device; }
Expand Down
30 changes: 15 additions & 15 deletions sycl/include/CL/sycl/detail/device_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ template <typename T, info::device param> struct get_device_info {
static T _(RT::PiDevice dev) {
typename sycl_to_pi<T>::type result;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
return T(result);
}
};
Expand All @@ -60,7 +60,7 @@ struct get_device_info<platform, param> {
static platform _(RT::PiDevice dev) {
typename sycl_to_pi<platform>::type result;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
return createSyclObjFromImpl<platform>(
std::make_shared<platform_impl_pi>(result));
}
Expand All @@ -71,13 +71,13 @@ template <info::device param> struct get_device_info<string_class, param> {
static string_class _(RT::PiDevice dev) {
size_t resultSize;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(param), 0, NULL, &resultSize));
dev, pi::cast<RT::PiDeviceInfo>(param), 0, NULL, &resultSize));
if (resultSize == 0) {
return string_class();
}
unique_ptr_class<char[]> result(new char[resultSize]);
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(param),
dev, pi::cast<RT::PiDeviceInfo>(param),
resultSize, result.get(), NULL));

return string_class(result.get());
Expand All @@ -95,7 +95,7 @@ template <info::device param> struct get_device_info<id<3>, param> {
static id<3> _(RT::PiDevice dev) {
size_t result[3];
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
return id<3>(result[0], result[1], result[2]);
}
};
Expand All @@ -113,7 +113,7 @@ struct get_device_info<vector_class<info::fp_config>, param> {
}
cl_device_fp_config result;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
dev, pi::cast<RT::PiDeviceInfo>(param), sizeof(result), &result, NULL));
return read_fp_bitfield(result);
}
};
Expand All @@ -125,7 +125,7 @@ struct get_device_info<vector_class<info::fp_config>,
static vector_class<info::fp_config> _(RT::PiDevice dev) {
cl_device_fp_config result;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::single_fp_config),
dev, pi::cast<RT::PiDeviceInfo>(info::device::single_fp_config),
sizeof(result), &result, NULL));
return read_fp_bitfield(result);
}
Expand All @@ -136,7 +136,7 @@ template <> struct get_device_info<bool, info::device::queue_profiling> {
static bool _(RT::PiDevice dev) {
cl_command_queue_properties result;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::queue_profiling),
dev, pi::cast<RT::PiDeviceInfo>(info::device::queue_profiling),
sizeof(result), &result, NULL));
return (result & CL_QUEUE_PROFILING_ENABLE);
}
Expand All @@ -149,7 +149,7 @@ struct get_device_info<vector_class<info::execution_capability>,
static vector_class<info::execution_capability> _(RT::PiDevice dev) {
cl_device_exec_capabilities result;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
dev, pi::cast<RT::PiDeviceInfo>(info::device::execution_capabilities),
sizeof(result), &result, NULL));
return read_execution_bitfield(result);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ struct get_device_info<vector_class<info::partition_property>,
info::device::partition_properties> {
static vector_class<info::partition_property> _(RT::PiDevice dev) {
auto info_partition =
pi::pi_cast<RT::PiDeviceInfo>(info::device::partition_properties);
pi::cast<RT::PiDeviceInfo>(info::device::partition_properties);

size_t resultSize;
PI_CALL(RT::piDeviceGetInfo(dev, info_partition, 0, NULL, &resultSize));
Expand Down Expand Up @@ -212,7 +212,7 @@ struct get_device_info<vector_class<info::partition_affinity_domain>,
static vector_class<info::partition_affinity_domain> _(RT::PiDevice dev) {
cl_device_affinity_domain result;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
dev, pi::cast<RT::PiDeviceInfo>(info::device::partition_affinity_domains),
sizeof(result), &result, NULL));
return read_domain_bitfield(result);
}
Expand All @@ -226,15 +226,15 @@ struct get_device_info<info::partition_affinity_domain,
static info::partition_affinity_domain _(RT::PiDevice dev) {
size_t resultSize;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(
dev, pi::cast<RT::PiDeviceInfo>(
info::device::partition_type_affinity_domain),
0, NULL, &resultSize));
if (resultSize != 1) {
return info::partition_affinity_domain::not_applicable;
}
cl_device_partition_property result;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(
dev, pi::cast<RT::PiDeviceInfo>(
info::device::partition_type_affinity_domain),
sizeof(result), &result, NULL));
if (result == CL_DEVICE_AFFINITY_DOMAIN_NUMA ||
Expand Down Expand Up @@ -278,12 +278,12 @@ struct get_device_info<vector_class<size_t>,
static vector_class<size_t> _(RT::PiDevice dev) {
size_t resultSize = 0;
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
0, nullptr, &resultSize));

vector_class<size_t> result(resultSize/sizeof(size_t));
PI_CALL(RT::piDeviceGetInfo(
dev, pi::pi_cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
dev, pi::cast<RT::PiDeviceInfo>(info::device::sub_group_sizes),
resultSize, result.data(), nullptr));
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {
image_impl(cl_mem MemObject, const context &SyclContext,
event AvailableEvent = {})
: BaseT(MemObject, SyclContext, std::move(AvailableEvent)) {
RT::PiMem Mem = pi::pi_cast<RT::PiMem>(BaseT::MInteropMemObject);
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
PI_CALL(RT::piMemGetInfo(Mem, CL_MEM_SIZE, sizeof(size_t),
&(BaseT::MSizeInBytes), nullptr));

Expand Down Expand Up @@ -340,7 +340,7 @@ class image_impl final : public SYCLMemObjT<AllocatorT> {

private:
template <typename T> void getImageInfo(RT::PiMemImageInfo Info, T &Dest) {
RT::PiMem Mem = pi::pi_cast<RT::PiMem>(BaseT::MInteropMemObject);
RT::PiMem Mem = pi::cast<RT::PiMem>(BaseT::MInteropMemObject);
PI_CALL(RT::piMemImageGetInfo(Mem, Info, sizeof(T), &Dest, nullptr));
}

Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/kernel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class kernel_impl {
throw invalid_object_error("This instance of kernel is a host instance");
}
PI_CALL(RT::piKernelRetain(Kernel));
return pi::pi_cast<cl_kernel>(Kernel);
return pi::cast<cl_kernel>(Kernel);
}

bool is_host() const { return Context.is_host(); }
Expand Down
30 changes: 15 additions & 15 deletions sycl/include/CL/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ namespace pi {
// For selection of SYCL RT back-end, now manually through the "SYCL_BE"
// environment variable.
//
enum PiBackend {
enum Backend {
SYCL_BE_PI_OPENCL,
SYCL_BE_PI_OTHER
};

// Check for manually selected BE at run-time.
bool piUseBackend(PiBackend Backend);
bool useBackend(Backend Backend);

using PiResult = ::pi_result;
using PiPlatform = ::pi_platform;
Expand Down Expand Up @@ -55,19 +55,19 @@ namespace pi {
std::string platformInfoToString(pi_platform_info info);

// Report error and no return (keeps compiler happy about no return statements).
[[noreturn]] void piDie(const char *Message);
void piAssert(bool Condition, const char *Message = nullptr);
[[noreturn]] void die(const char *Message);
void assertion(bool Condition, const char *Message = nullptr);

// Want all the needed casts be explicit, do not define conversion operators.
template<class To, class From>
To pi_cast(From value);
To cast(From value);

// Forward declarations of the PI dispatch entries.
#define _PI_API(api) __SYCL_EXPORTED extern decltype(::api) * api;
#include <CL/sycl/detail/pi.def>

// Performs PI one-time initialization.
void piInitialize();
void initialize();

// The PiCall helper structure facilitates performing a call to PI.
// It holds utilities to do the tracing and to check the returned result.
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace pi {
if (m_TraceEnabled)
printArgs(args...);

piInitialize();
initialize();
auto r = m_FnPtr(args...);

if (m_TraceEnabled) {
Expand All @@ -145,35 +145,35 @@ namespace pi {
namespace RT = cl::sycl::detail::pi;

#define PI_ASSERT(cond, msg) \
RT::piAssert((cond), "assert @ " __FILE__ ":" STRINGIFY_LINE(__LINE__) msg);
RT::assertion((cond), "assert @ " __FILE__ ":" STRINGIFY_LINE(__LINE__) msg);

#define PI_TRACE(func) RT::Trace<decltype(func)>(func, #func)

// This does the call, the trace and the check for no errors.
#define PI_CALL(pi) \
RT::piInitialize(), \
RT::initialize(), \
RT::PiCall(#pi).check<cl::sycl::runtime_error>( \
RT::pi_cast<detail::RT::PiResult>(pi))
RT::cast<detail::RT::PiResult>(pi))

// This does the trace, the call, and returns the result
#define PI_CALL_RESULT(pi) \
RT::PiCall(#pi).get(detail::RT::pi_cast<detail::RT::PiResult>(pi))
RT::PiCall(#pi).get(detail::RT::cast<detail::RT::PiResult>(pi))

// This does the check for no errors and possibly throws
#define PI_CHECK(pi) \
RT::PiCall().check<cl::sycl::runtime_error>( \
RT::pi_cast<detail::RT::PiResult>(pi))
RT::cast<detail::RT::PiResult>(pi))

// This does the check for no errors and possibly throws x
#define PI_CHECK_THROW(pi, x) \
RT::PiCall().check<x>( \
RT::pi_cast<detail::RT::PiResult>(pi))
RT::cast<detail::RT::PiResult>(pi))

// Want all the needed casts be explicit, do not define conversion operators.
template<class To, class From>
To pi::pi_cast(From value) {
To pi::cast(From value) {
// TODO: see if more sanity checks are possible.
PI_ASSERT(sizeof(From) == sizeof(To), "pi_cast failed size check");
PI_ASSERT(sizeof(From) == sizeof(To), "cast failed size check");
return (To)(value);
}

Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/platform_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class platform_impl_pi : public platform_impl {
return (all_extension_names.find(extension_name) != std::string::npos);
}

cl_platform_id get() const override { return pi::pi_cast<cl_platform_id>(m_platform); }
cl_platform_id get() const override { return pi::cast<cl_platform_id>(m_platform); }

const RT::PiPlatform &getHandleRef() const override { return m_platform; }

Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/platform_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ struct get_platform_info<string_class, param> {
size_t resultSize;
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piPlatformGetInfo(
plt, pi::pi_cast<pi_platform_info>(param), 0, 0, &resultSize));
plt, pi::cast<pi_platform_info>(param), 0, 0, &resultSize));
if (resultSize == 0) {
return "";
}
unique_ptr_class<char[]> result(new char[resultSize]);
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piPlatformGetInfo(
plt, pi::pi_cast<pi_platform_info>(param), resultSize, result.get(), 0));
plt, pi::cast<pi_platform_info>(param), resultSize, result.get(), 0));
return result.get();
}
};
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/program_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class program_impl {
throw invalid_object_error("This instance of program is a host instance");
}
PI_CALL(RT::piProgramRetain(Program));
return pi::pi_cast<cl_program>(Program);
return pi::cast<cl_program>(Program);
}

bool is_host() const { return Context.is_host(); }
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class queue_impl {
: m_Context(SyclContext), m_AsyncHandler(AsyncHandler),
m_OpenCLInterop(true), m_HostQueue(false) {

m_CommandQueue = pi::pi_cast<RT::PiQueue>(CLQueue);
m_CommandQueue = pi::cast<RT::PiQueue>(CLQueue);

RT::PiDevice Device = nullptr;
// TODO catch an exception and put it to list of asynchronous exceptions
Expand Down Expand Up @@ -73,7 +73,7 @@ class queue_impl {
cl_command_queue get() {
if (m_OpenCLInterop) {
PI_CALL(RT::piQueueRetain(m_CommandQueue));
return pi::pi_cast<cl_command_queue>(m_CommandQueue);
return pi::cast<cl_command_queue>(m_CommandQueue);
}
throw invalid_object_error(
"This instance of queue doesn't support OpenCL interoperability");
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ template <typename AllocatorT> class SYCLMemObjT : public SYCLMemObjI {
"Creation of interoperability memory object using host context is "
"not allowed");

RT::PiMem Mem = pi::pi_cast<RT::PiMem>(MInteropMemObject);
RT::PiMem Mem = pi::cast<RT::PiMem>(MInteropMemObject);
RT::PiContext Context = nullptr;
PI_CALL(RT::piMemGetInfo(Mem, CL_MEM_CONTEXT, sizeof(Context), &Context,
nullptr));
Expand Down Expand Up @@ -225,7 +225,7 @@ template <typename AllocatorT> class SYCLMemObjT : public SYCLMemObjI {
releaseHostMem(MShadowCopy);

if (MOpenCLInterop)
PI_CALL(RT::piMemRelease(pi::pi_cast<RT::PiMem>(MInteropMemObject)));
PI_CALL(RT::piMemRelease(pi::cast<RT::PiMem>(MInteropMemObject)));
}

bool useHostPtr() {
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/kernel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class kernel {
public:
kernel(cl_kernel clKernel, const context &syclContext)
: impl(std::make_shared<detail::kernel_impl>(
detail::pi::pi_cast<detail::RT::PiKernel>(clKernel), syclContext)) {}
detail::pi::cast<detail::RT::PiKernel>(clKernel), syclContext)) {}

kernel(const kernel &rhs) = default;

Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class program {

program(const context &context, cl_program clProgram)
: impl(std::make_shared<detail::program_impl>(
context, detail::pi::pi_cast<detail::RT::PiProgram>(clProgram))) {}
context, detail::pi::cast<detail::RT::PiProgram>(clProgram))) {}

program(const program &rhs) = default;

Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ context_impl::context_impl(cl_context ClContext, async_handler AsyncHandler)
: m_AsyncHandler(AsyncHandler), m_Devices(),
m_Platform(), m_OpenCLInterop(true), m_HostContext(false) {

m_Context = pi::pi_cast<RT::PiContext>(ClContext);
m_Context = pi::cast<RT::PiContext>(ClContext);
vector_class<RT::PiDevice> DeviceIds;
size_t DevicesNum = 0;
// TODO catch an exception and put it to list of asynchronous exceptions
Expand All @@ -77,7 +77,7 @@ cl_context context_impl::get() const {
if (m_OpenCLInterop) {
// TODO catch an exception and put it to list of asynchronous exceptions
PI_CALL(RT::piContextRetain(m_Context));
return pi::pi_cast<cl_context>(m_Context);
return pi::cast<cl_context>(m_Context);
}
throw invalid_object_error(
"This instance of event doesn't support OpenCL interoperability.");
Expand Down
Loading