Skip to content

[SYCL] Non-standard RT namespace removed (#7133) #9972

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 4 commits into from
Jun 22, 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
7 changes: 4 additions & 3 deletions sycl/include/sycl/detail/backend_traits_opencl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,10 @@ namespace pi {
// Cast for std::vector<cl_event>, according to the spec, make_event
// should create one(?) event from a vector of cl_event
template <class To> inline To cast(std::vector<cl_event> value) {
RT::assertion(value.size() == 1,
"Temporary workaround requires that the "
"size of the input vector for make_event be equal to one.");
sycl::detail::pi::assertion(
value.size() == 1,
"Temporary workaround requires that the "
"size of the input vector for make_event be equal to one.");
return cast<To>(value[0]);
}

Expand Down
5 changes: 3 additions & 2 deletions sycl/include/sycl/detail/cg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class CGExecKernel : public CG {
std::string MKernelName;
std::vector<std::shared_ptr<detail::stream_impl>> MStreams;
std::vector<std::shared_ptr<const void>> MAuxiliaryResources;
RT::PiKernelCacheConfig MKernelCacheConfig;
sycl::detail::pi::PiKernelCacheConfig MKernelCacheConfig;

CGExecKernel(NDRDescT NDRDesc, std::shared_ptr<HostKernelBase> HKernel,
std::shared_ptr<detail::kernel_impl> SyclKernel,
Expand All @@ -176,7 +176,8 @@ class CGExecKernel : public CG {
std::string KernelName,
std::vector<std::shared_ptr<detail::stream_impl>> Streams,
std::vector<std::shared_ptr<const void>> AuxiliaryResources,
CGTYPE Type, RT::PiKernelCacheConfig KernelCacheConfig,
CGTYPE Type,
sycl::detail::pi::PiKernelCacheConfig KernelCacheConfig,
detail::code_location loc = {})
: CG(Type, std::move(CGData), std::move(loc)),
MNDRDesc(std::move(NDRDesc)), MHostKernel(std::move(HKernel)),
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/detail/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace detail {
class context_impl;
// The function returns list of events that can be passed to OpenCL API as
// dependency list and waits for others.
__SYCL_EXPORT std::vector<RT::PiEvent>
__SYCL_EXPORT std::vector<sycl::detail::pi::PiEvent>
getOrWaitEvents(std::vector<sycl::event> DepEvents,
std::shared_ptr<sycl::detail::context_impl> Context);

Expand Down
5 changes: 2 additions & 3 deletions sycl/include/sycl/detail/pi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,6 @@ PiDeviceBinaryType getBinaryImageFormat(const unsigned char *ImgData,

} // namespace pi

namespace RT = sycl::detail::pi;

// Workaround for build with GCC 5.x
// An explicit specialization shall be declared in the namespace block.
// Having namespace as part of template name is not supported by GCC
Expand All @@ -253,7 +251,8 @@ namespace pi {
// operators.
template <class To, class From> inline To cast(From value) {
// TODO: see if more sanity checks are possible.
RT::assertion((sizeof(From) == sizeof(To)), "assert: cast failed size check");
sycl::detail::pi::assertion((sizeof(From) == sizeof(To)),
"assert: cast failed size check");
return (To)(value);
}

Expand Down
4 changes: 2 additions & 2 deletions sycl/source/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ __SYCL_EXPORT queue make_queue(pi_native_handle NativeHandle,
const device *Device, bool KeepOwnership,
const property_list &PropList,
const async_handler &Handler, backend Backend) {
RT::PiDevice PiDevice =
sycl::detail::pi::PiDevice PiDevice =
Device ? getSyclObjImpl(*Device)->getHandleRef() : nullptr;
const auto &Plugin = getPlugin(Backend);
const auto &ContextImpl = getSyclObjImpl(Context);

// Create PI properties from SYCL properties.
RT::PiQueueProperties Properties[] = {
sycl::detail::pi::PiQueueProperties Properties[] = {
PI_QUEUE_FLAGS,
queue_impl::createPiQueueProperties(
PropList, PropList.has_property<property::queue::in_order>()
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/backend/opencl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ __SYCL_EXPORT bool has_extension(const sycl::platform &SyclPlatform,

std::shared_ptr<sycl::detail::platform_impl> PlatformImpl =
getSyclObjImpl(SyclPlatform);
detail::RT::PiPlatform PluginPlatform = PlatformImpl->getHandleRef();
sycl::detail::pi::PiPlatform PluginPlatform = PlatformImpl->getHandleRef();
const PluginPtr &Plugin = PlatformImpl->getPlugin();

// Manual invocation of plugin API to avoid using deprecated
Expand Down Expand Up @@ -92,7 +92,7 @@ __SYCL_EXPORT bool has_extension(const sycl::device &SyclDevice,

std::shared_ptr<sycl::detail::device_impl> DeviceImpl =
getSyclObjImpl(SyclDevice);
detail::RT::PiDevice PluginDevice = DeviceImpl->getHandleRef();
sycl::detail::pi::PiDevice PluginDevice = DeviceImpl->getHandleRef();
const PluginPtr &Plugin = DeviceImpl->getPlugin();

// Manual invocation of plugin API to avoid using deprecated
Expand Down
3 changes: 2 additions & 1 deletion sycl/source/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ context::context(const std::vector<device> &DeviceList,
context::context(cl_context ClContext, async_handler AsyncHandler) {
const auto &Plugin = sycl::detail::pi::getPlugin<backend::opencl>();
impl = std::make_shared<detail::context_impl>(
detail::pi::cast<detail::RT::PiContext>(ClContext), AsyncHandler, Plugin);
detail::pi::cast<sycl::detail::pi::PiContext>(ClContext), AsyncHandler,
Plugin);
}

template <typename Param>
Expand Down
15 changes: 8 additions & 7 deletions sycl/source/detail/allowlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,9 @@ bool deviceIsAllowed(const DeviceDescT &DeviceDesc,
return ShouldDeviceBeAllowed;
}

void applyAllowList(std::vector<RT::PiDevice> &PiDevices,
RT::PiPlatform PiPlatform, const PluginPtr &Plugin) {
void applyAllowList(std::vector<sycl::detail::pi::PiDevice> &PiDevices,
sycl::detail::pi::PiPlatform PiPlatform,
const PluginPtr &Plugin) {

AllowListParsedT AllowListParsed =
parseAllowList(SYCLConfig<SYCL_DEVICE_ALLOWLIST>::get());
Expand Down Expand Up @@ -363,13 +364,13 @@ void applyAllowList(std::vector<RT::PiDevice> &PiDevices,
PiPlatform, Plugin));

int InsertIDx = 0;
for (RT::PiDevice Device : PiDevices) {
for (sycl::detail::pi::PiDevice Device : PiDevices) {
auto DeviceImpl = PlatformImpl->getOrMakeDeviceImpl(Device, PlatformImpl);
// get DeviceType value and put it to DeviceDesc
RT::PiDeviceType PiDevType;
Plugin->call<PiApiKind::piDeviceGetInfo>(Device, PI_DEVICE_INFO_TYPE,
sizeof(RT::PiDeviceType),
&PiDevType, nullptr);
sycl::detail::pi::PiDeviceType PiDevType;
Plugin->call<PiApiKind::piDeviceGetInfo>(
Device, PI_DEVICE_INFO_TYPE, sizeof(sycl::detail::pi::PiDeviceType),
&PiDevType, nullptr);
sycl::info::device_type DeviceType = pi::cast<info::device_type>(PiDevType);
for (const auto &SyclDeviceType : getSyclDeviceTypeMap()) {
if (SyclDeviceType.second == DeviceType) {
Expand Down
5 changes: 3 additions & 2 deletions sycl/source/detail/allowlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw);
bool deviceIsAllowed(const DeviceDescT &DeviceDesc,
const AllowListParsedT &AllowListParsed);

void applyAllowList(std::vector<RT::PiDevice> &PiDevices,
RT::PiPlatform PiPlatform, const PluginPtr &Plugin);
void applyAllowList(std::vector<sycl::detail::pi::PiDevice> &PiDevices,
sycl::detail::pi::PiPlatform PiPlatform,
const PluginPtr &Plugin);

} // namespace detail
} // __SYCL_INLINE_VER_NAMESPACE(_V1)
Expand Down
8 changes: 5 additions & 3 deletions sycl/source/detail/buffer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace detail {
uint8_t GBufferStreamID;
#endif
void *buffer_impl::allocateMem(ContextImplPtr Context, bool InitFromUserData,
void *HostPtr, RT::PiEvent &OutEventToWait) {
void *HostPtr,
sycl::detail::pi::PiEvent &OutEventToWait) {
bool HostPtrReadOnly = false;
BaseT::determineHostPtr(Context, InitFromUserData, HostPtr, HostPtrReadOnly);

Expand Down Expand Up @@ -52,7 +53,7 @@ void buffer_impl::addInteropObject(
Handles.end()) {
const PluginPtr &Plugin = getPlugin();
Plugin->call<PiApiKind::piMemRetain>(
pi::cast<RT::PiMem>(MInteropMemObject));
pi::cast<sycl::detail::pi::PiMem>(MInteropMemObject));
Handles.push_back(pi::cast<pi_native_handle>(MInteropMemObject));
}
}
Expand All @@ -67,7 +68,8 @@ buffer_impl::getNativeVector(backend BackendName) const {
}

for (auto &Cmd : MRecord->MAllocaCommands) {
RT::PiMem NativeMem = pi::cast<RT::PiMem>(Cmd->getMemAllocation());
sycl::detail::pi::PiMem NativeMem =
pi::cast<sycl::detail::pi::PiMem>(Cmd->getMemAllocation());
auto Ctx = Cmd->getWorkerContext();
auto Platform = Ctx->getPlatformImpl();
// If Host Shared Memory is not supported then there is alloca for host that
Expand Down
3 changes: 2 additions & 1 deletion sycl/source/detail/buffer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
std::move(Allocator)) {}

void *allocateMem(ContextImplPtr Context, bool InitFromUserData,
void *HostPtr, RT::PiEvent &OutEventToWait) override;
void *HostPtr,
sycl::detail::pi::PiEvent &OutEventToWait) override;
void constructorNotification(const detail::code_location &CodeLoc,
void *UserObj, const void *HostObj,
const void *Type, uint32_t Dim,
Expand Down
53 changes: 29 additions & 24 deletions sycl/source/detail/context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ context_impl::context_impl(const std::vector<sycl::device> Devices,
MPlatform(), MPropList(PropList), MHostContext(false),
MSupportBufferLocationByDevices(NotChecked) {
MPlatform = detail::getSyclObjImpl(MDevices[0].get_platform());
std::vector<RT::PiDevice> DeviceIds;
std::vector<sycl::detail::pi::PiDevice> DeviceIds;
for (const auto &D : MDevices) {
DeviceIds.push_back(getSyclObjImpl(D)->getHandleRef());
}
Expand All @@ -69,27 +69,27 @@ context_impl::context_impl(const std::vector<sycl::device> Devices,
MKernelProgramCache.setContextPtr(this);
}

context_impl::context_impl(RT::PiContext PiContext, async_handler AsyncHandler,
const PluginPtr &Plugin)
context_impl::context_impl(sycl::detail::pi::PiContext PiContext,
async_handler AsyncHandler, const PluginPtr &Plugin)
: MAsyncHandler(AsyncHandler), MDevices(), MContext(PiContext), MPlatform(),
MHostContext(false), MSupportBufferLocationByDevices(NotChecked) {

std::vector<RT::PiDevice> DeviceIds;
std::vector<sycl::detail::pi::PiDevice> DeviceIds;
size_t DevicesNum = 0;
// TODO catch an exception and put it to list of asynchronous exceptions
Plugin->call<PiApiKind::piContextGetInfo>(
MContext, PI_CONTEXT_INFO_NUM_DEVICES, sizeof(DevicesNum), &DevicesNum,
nullptr);
DeviceIds.resize(DevicesNum);
// TODO catch an exception and put it to list of asynchronous exceptions
Plugin->call<PiApiKind::piContextGetInfo>(MContext, PI_CONTEXT_INFO_DEVICES,
sizeof(RT::PiDevice) * DevicesNum,
&DeviceIds[0], nullptr);
Plugin->call<PiApiKind::piContextGetInfo>(
MContext, PI_CONTEXT_INFO_DEVICES,
sizeof(sycl::detail::pi::PiDevice) * DevicesNum, &DeviceIds[0], nullptr);

if (!DeviceIds.empty()) {
std::shared_ptr<detail::platform_impl> Platform =
platform_impl::getPlatformFromPiDevice(DeviceIds[0], Plugin);
for (RT::PiDevice Dev : DeviceIds) {
for (sycl::detail::pi::PiDevice Dev : DeviceIds) {
MDevices.emplace_back(createSyclObjFromImpl<device>(
Platform->getOrMakeDeviceImpl(Dev, Platform)));
}
Expand Down Expand Up @@ -230,8 +230,10 @@ context_impl::get_info<info::context::atomic_fence_scope_capabilities>() const {
return CapabilityList;
}

RT::PiContext &context_impl::getHandleRef() { return MContext; }
const RT::PiContext &context_impl::getHandleRef() const { return MContext; }
sycl::detail::pi::PiContext &context_impl::getHandleRef() { return MContext; }
const sycl::detail::pi::PiContext &context_impl::getHandleRef() const {
return MContext;
}

KernelProgramCache &context_impl::getKernelProgramCache() const {
return MKernelProgramCache;
Expand All @@ -245,8 +247,8 @@ bool context_impl::hasDevice(
return false;
}

DeviceImplPtr
context_impl::findMatchingDeviceImpl(RT::PiDevice &DevicePI) const {
DeviceImplPtr context_impl::findMatchingDeviceImpl(
sycl::detail::pi::PiDevice &DevicePI) const {
for (device D : MDevices)
if (getSyclObjImpl(D)->getHandleRef() == DevicePI)
return getSyclObjImpl(D);
Expand Down Expand Up @@ -283,7 +285,7 @@ void context_impl::addAssociatedDeviceGlobal(const void *DeviceGlobalPtr) {
}

void context_impl::addDeviceGlobalInitializer(
RT::PiProgram Program, const std::vector<device> &Devs,
sycl::detail::pi::PiProgram Program, const std::vector<device> &Devs,
const RTDeviceBinaryImage *BinImage) {
std::lock_guard<std::mutex> Lock(MDeviceGlobalInitializersMutex);
for (const device &Dev : Devs) {
Expand All @@ -292,7 +294,7 @@ void context_impl::addDeviceGlobalInitializer(
}
}

std::vector<RT::PiEvent> context_impl::initializeDeviceGlobals(
std::vector<sycl::detail::pi::PiEvent> context_impl::initializeDeviceGlobals(
pi::PiProgram NativePrg, const std::shared_ptr<queue_impl> &QueueImpl) {
const PluginPtr &Plugin = getPlugin();
const DeviceImplPtr &DeviceImpl = QueueImpl->getDeviceImplPtr();
Expand All @@ -306,12 +308,13 @@ std::vector<RT::PiEvent> context_impl::initializeDeviceGlobals(
DeviceGlobalInitializer &InitRef = ImgIt->second;
{
std::lock_guard<std::mutex> InitLock(InitRef.MDeviceGlobalInitMutex);
std::vector<RT::PiEvent> &InitEventsRef = InitRef.MDeviceGlobalInitEvents;
std::vector<sycl::detail::pi::PiEvent> &InitEventsRef =
InitRef.MDeviceGlobalInitEvents;
if (!InitEventsRef.empty()) {
// Initialization has begun but we do not know if the events are done.
auto NewEnd = std::remove_if(
InitEventsRef.begin(), InitEventsRef.end(),
[&Plugin](const RT::PiEvent &Event) {
[&Plugin](const sycl::detail::pi::PiEvent &Event) {
return get_event_info<info::event::command_execution_status>(
Event, Plugin) == info::event_command_status::complete;
});
Expand Down Expand Up @@ -373,7 +376,7 @@ std::vector<RT::PiEvent> context_impl::initializeDeviceGlobals(

// Write the pointer to the device global and store the event in the
// initialize events list.
RT::PiEvent InitEvent;
sycl::detail::pi::PiEvent InitEvent;
void *const &USMPtr = DeviceGlobalUSM.getPtr();
Plugin->call<PiApiKind::piextEnqueueDeviceGlobalVariableWrite>(
QueueImpl->getHandleRef(), NativePrg,
Expand All @@ -389,7 +392,7 @@ std::vector<RT::PiEvent> context_impl::initializeDeviceGlobals(

void context_impl::DeviceGlobalInitializer::ClearEvents(
const PluginPtr &Plugin) {
for (const RT::PiEvent &Event : MDeviceGlobalInitEvents)
for (const sycl::detail::pi::PiEvent &Event : MDeviceGlobalInitEvents)
Plugin->call<PiApiKind::piEventRelease>(Event);
MDeviceGlobalInitEvents.clear();
}
Expand All @@ -398,7 +401,7 @@ void context_impl::memcpyToHostOnlyDeviceGlobal(
const std::shared_ptr<device_impl> &DeviceImpl, const void *DeviceGlobalPtr,
const void *Src, size_t DeviceGlobalTSize, bool IsDeviceImageScoped,
size_t NumBytes, size_t Offset) {
std::optional<RT::PiDevice> KeyDevice = std::nullopt;
std::optional<sycl::detail::pi::PiDevice> KeyDevice = std::nullopt;
if (IsDeviceImageScoped)
KeyDevice = DeviceImpl->getHandleRef();
auto Key = std::make_pair(DeviceGlobalPtr, KeyDevice);
Expand All @@ -421,7 +424,7 @@ void context_impl::memcpyFromHostOnlyDeviceGlobal(
const void *DeviceGlobalPtr, bool IsDeviceImageScoped, size_t NumBytes,
size_t Offset) {

std::optional<RT::PiDevice> KeyDevice = std::nullopt;
std::optional<sycl::detail::pi::PiDevice> KeyDevice = std::nullopt;
if (IsDeviceImageScoped)
KeyDevice = DeviceImpl->getHandleRef();
auto Key = std::make_pair(DeviceGlobalPtr, KeyDevice);
Expand All @@ -440,7 +443,7 @@ void context_impl::memcpyFromHostOnlyDeviceGlobal(
std::memcpy(Dest, ValuePtr + Offset, NumBytes);
}

std::optional<RT::PiProgram> context_impl::getProgramForDevImgs(
std::optional<sycl::detail::pi::PiProgram> context_impl::getProgramForDevImgs(
const device &Device, const std::set<std::uintptr_t> &ImgIdentifiers,
const std::string &ObjectTypeName) {

Expand All @@ -449,7 +452,8 @@ std::optional<RT::PiProgram> context_impl::getProgramForDevImgs(
auto LockedCache = MKernelProgramCache.acquireCachedPrograms();
auto &KeyMap = LockedCache.get().KeyMap;
auto &Cache = LockedCache.get().Cache;
RT::PiDevice &DevHandle = getSyclObjImpl(Device)->getHandleRef();
sycl::detail::pi::PiDevice &DevHandle =
getSyclObjImpl(Device)->getHandleRef();
for (std::uintptr_t ImageIDs : ImgIdentifiers) {
auto OuterKey = std::make_pair(ImageIDs, DevHandle);
size_t NProgs = KeyMap.count(OuterKey);
Expand All @@ -475,13 +479,14 @@ std::optional<RT::PiProgram> context_impl::getProgramForDevImgs(
return *MKernelProgramCache.waitUntilBuilt<compile_program_error>(BuildRes);
}

std::optional<RT::PiProgram> context_impl::getProgramForDeviceGlobal(
std::optional<sycl::detail::pi::PiProgram>
context_impl::getProgramForDeviceGlobal(
const device &Device, DeviceGlobalMapEntry *DeviceGlobalEntry) {
return getProgramForDevImgs(Device, DeviceGlobalEntry->MImageIdentifiers,
"device_global");
}
/// Gets a program associated with a HostPipe Entry from the cache.
std::optional<RT::PiProgram>
std::optional<sycl::detail::pi::PiProgram>
context_impl::getProgramForHostPipe(const device &Device,
HostPipeMapEntry *HostPipeEntry) {
// One HostPipe entry belongs to one Img
Expand Down
Loading