SWDEV-367145 - adding support for timeline semaphore
Change-Id: I654359b48abe8bbaac2def5118d3ad0bb05d9492
Bu işleme şunda yer alıyor:
işlemeyi yapan:
Payam Ghafari
ebeveyn
261ce9837c
işleme
afa15ddb89
@@ -181,14 +181,16 @@ hipError_t hipImportExternalSemaphore(hipExternalSemaphore_t* extSem_out,
|
||||
(semHandleDesc->type > hipExternalSemaphoreHandleTypeD3D12Fence)) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
|
||||
amd::Device* device = hip::getCurrentDevice()->devices()[0];
|
||||
|
||||
#ifdef _WIN32
|
||||
if (device->importExtSemaphore(extSem_out, semHandleDesc->handle.win32.handle)) {
|
||||
if (device->importExtSemaphore(extSem_out, semHandleDesc->handle.win32.handle,
|
||||
static_cast <amd::ExternalSemaphoreHandleType>
|
||||
(semHandleDesc->type))) {
|
||||
#else
|
||||
if (device->importExtSemaphore(
|
||||
extSem_out, semHandleDesc->handle.fd)) {
|
||||
if (device->importExtSemaphore(extSem_out, semHandleDesc->handle.fd,
|
||||
static_cast <amd::ExternalSemaphoreHandleType>
|
||||
(semHandleDesc->type))) {
|
||||
#endif
|
||||
HIP_RETURN(hipSuccess);
|
||||
}
|
||||
|
||||
@@ -123,6 +123,26 @@ enum MemRangeAttribute : uint32_t {
|
||||
constexpr int CpuDeviceId = static_cast<int>(-1);
|
||||
constexpr int InvalidDeviceId = static_cast<int>(-2);
|
||||
|
||||
enum class ExternalSemaphoreHandleType : uint32_t {
|
||||
OpaqueFd = 1, // Handle is an opaque file descriptor
|
||||
OpaqueWin32 = 2, // Handle is an opaque shared NT handle
|
||||
OpaqueWin32Kmt = 3, // Handle is an opaque, globally shared handle
|
||||
D3D12Fence = 4, // Handle is a shared NT handle referencing a
|
||||
// D3D12 fence object
|
||||
D3D11Fence = 5, // Handle is a shared NT handle referencing a
|
||||
// D3D11 fence object
|
||||
NvSciSync = 6, // Opaque handle to NvSciSync Object
|
||||
KeyedMutex = 7, // Handle is a shared NT handle referencing a
|
||||
// D3D11 keyed mutex object
|
||||
KeyedMutexKmt = 8, // Handle is a shared KMT handle referencing a
|
||||
// D3D11 keyed mutex object
|
||||
TimelineSemaphoreFd = 9, // Handle is an opaque handle file
|
||||
// descriptor referencing a timeline
|
||||
// semaphore
|
||||
TimelineSemaphoreWin32 = 10, // Handle is an opaque handle file
|
||||
// descriptor referencing a timeline
|
||||
// semaphore
|
||||
};
|
||||
} // namespace amd
|
||||
|
||||
enum OclExtensions {
|
||||
@@ -1696,7 +1716,8 @@ class Device : public RuntimeObject {
|
||||
virtual bool globalFreeMemory(size_t* freeMemory //!< Free memory information on a GPU device
|
||||
) const = 0;
|
||||
|
||||
virtual bool importExtSemaphore(void** extSemaphore, const amd::Os::FileDesc& handle) = 0;
|
||||
virtual bool importExtSemaphore(void** extSemaphore, const amd::Os::FileDesc& handle,
|
||||
amd::ExternalSemaphoreHandleType sem_handle_type) = 0;
|
||||
virtual void DestroyExtSemaphore(void* extSemaphore) = 0;
|
||||
/**
|
||||
* @return True if the device has its own custom host allocator to be used
|
||||
|
||||
@@ -2545,11 +2545,18 @@ bool Device::SetClockMode(const cl_set_device_clock_mode_input_amd setClockModeI
|
||||
}
|
||||
|
||||
|
||||
bool Device::importExtSemaphore(void** extSemaphore, const amd::Os::FileDesc& handle) {
|
||||
bool Device::importExtSemaphore(void** extSemaphore, const amd::Os::FileDesc& handle,
|
||||
amd::ExternalSemaphoreHandleType sem_handle_type) {
|
||||
Pal::ExternalQueueSemaphoreOpenInfo palOpenInfo = {};
|
||||
palOpenInfo.externalSemaphore = handle;
|
||||
palOpenInfo.flags.crossProcess = false;
|
||||
palOpenInfo.flags.isReference = true;
|
||||
palOpenInfo.flags.timeline =
|
||||
palOpenInfo.flags.timeline =
|
||||
(sem_handle_type == amd::ExternalSemaphoreHandleType::TimelineSemaphoreWin32 ||
|
||||
sem_handle_type == amd::ExternalSemaphoreHandleType::TimelineSemaphoreFd);
|
||||
palOpenInfo.flags.sharedViaNtHandle =
|
||||
(sem_handle_type == amd::ExternalSemaphoreHandleType::OpaqueWin32);
|
||||
Pal::Result result;
|
||||
|
||||
size_t semaphoreSize = iDev()->GetExternalSharedQueueSemaphoreSize(
|
||||
|
||||
@@ -147,7 +147,10 @@ class NullDevice : public amd::Device {
|
||||
virtual void* virtualAlloc(void* addr, size_t size, size_t alignment) { return nullptr; };
|
||||
virtual void virtualFree(void* addr) { };
|
||||
|
||||
virtual bool importExtSemaphore(void** extSemaphore,const amd::Os::FileDesc& handle) { return false; }
|
||||
virtual bool importExtSemaphore(void** extSemaphore,const amd::Os::FileDesc& handle,
|
||||
amd::ExternalSemaphoreHandleType sem_handle_type) override {
|
||||
return false;
|
||||
}
|
||||
virtual void DestroyExtSemaphore(void* extSemaphore) { }
|
||||
|
||||
void* Alloc(const Util::AllocInfo& allocInfo) { return allocator_.Alloc(allocInfo); }
|
||||
@@ -619,7 +622,9 @@ class Device : public NullDevice {
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool importExtSemaphore(void** extSemaphore, const amd::Os::FileDesc& handle);
|
||||
virtual bool importExtSemaphore(void** extSemaphore, const amd::Os::FileDesc& handle,
|
||||
amd::ExternalSemaphoreHandleType sem_handle_type) override;
|
||||
|
||||
virtual void DestroyExtSemaphore(void* extSemaphore);
|
||||
#if defined(__clang__)
|
||||
#if __has_feature(address_sanitizer)
|
||||
|
||||
@@ -221,7 +221,8 @@ class NullDevice : public amd::Device {
|
||||
return !settings().enableCoarseGrainSVM_ || (memory->getContext().devices().size() > 1);
|
||||
}
|
||||
|
||||
virtual bool importExtSemaphore(void** extSemahore, const amd::Os::FileDesc& handle) {
|
||||
virtual bool importExtSemaphore(void** extSemahore, const amd::Os::FileDesc& handle,
|
||||
amd::ExternalSemaphoreHandleType sem_handle_type) override {
|
||||
ShouldNotReachHere();
|
||||
return false;
|
||||
}
|
||||
|
||||
Yeni konuda referans
Bir kullanıcı engelle