06056e3adc
SWDEV-94640 - [OCL-LC-ROCm] OpenCL Runtime Library Implements OpenCL runtime API. Add HSA virtual device to ORCA. - Rename hsa_foundation to ROCm Affected files ... ... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#133 edit ... //depot/stg/opencl/drivers/opencl/runtime/Makefile#22 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#196 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#275 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/Makefile#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/build/Makefile#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/build/Makefile.oclhsa#7 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaappprofile.cpp#4 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaappprofile.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsabinary.cpp#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsabinary.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsablit.cpp#17 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsablit.hpp#5 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsacompiler.cpp#6 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsacompilerlib.cpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsacompilerlib.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadefs.hpp#6 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.cpp#65 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsadevice.hpp#31 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaglinterop.cpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaglinterop.hpp#3 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsakernel.cpp#18 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsakernel.hpp#12 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.cpp#27 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsamemory.hpp#13 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaprintf.cpp#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaprintf.hpp#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaprogram.cpp#28 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaprogram.hpp#11 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsaregisters.hpp#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsasettings.cpp#13 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsasettings.hpp#8 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsavirtual.cpp#67 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/hsavirtual.hpp#28 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/hsa_foundation/mesa_glinterop.h#2 delete ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile.oclrocm#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/wNow64a/Makefile#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/mesa_glinterop.h#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocappprofile.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocappprofile.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocbinary.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocblit.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocblit.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompiler.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompilerlib.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/roccompilerlib.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdefs.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocglinterop.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocglinterop.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocmemory.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprintf.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocregisters.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.hpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#1 add ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.hpp#1 add
121 خطوط
2.9 KiB
C++
121 خطوط
2.9 KiB
C++
//
|
|
// Copyright (c) 2016 Advanced Micro Devices, Inc. All rights reserved.
|
|
//
|
|
|
|
#ifndef WITHOUT_HSA_BACKEND
|
|
|
|
#include "os/os.hpp"
|
|
#include "utils/debug.hpp"
|
|
#include "utils/flags.hpp"
|
|
#include "device/rocm/rocglinterop.hpp"
|
|
|
|
#if !defined(_WIN32)
|
|
#include <dlfcn.h>
|
|
#endif
|
|
|
|
namespace roc
|
|
{
|
|
|
|
#if !defined(_WIN32)
|
|
static PFNMESAGLINTEROPGLXQUERYDEVICEINFOPROC GlxInfo = nullptr;
|
|
static PFNMESAGLINTEROPGLXEXPORTOBJECTPROC GlxExport = nullptr;
|
|
static PFNMESAGLINTEROPEGLQUERYDEVICEINFOPROC EglInfo = nullptr;
|
|
static PFNMESAGLINTEROPEGLEXPORTOBJECTPROC EglExport = nullptr;
|
|
#endif
|
|
|
|
std::atomic<uint32_t> MesaInterop::refCount(0);
|
|
|
|
bool MesaInterop::Supported()
|
|
{
|
|
#ifdef _WIN32
|
|
return false;
|
|
#else
|
|
return true;
|
|
#endif
|
|
}
|
|
|
|
//Attempt to locate Mesa interop APIs. Return which of glx/egl are supported.
|
|
bool MesaInterop::Bind(MESA_INTEROP_KIND Kind, const DisplayHandle& Display, const ContextHandle& Context)
|
|
{
|
|
#if defined(_WIN32)
|
|
return false;
|
|
#else
|
|
if(Kind==MESA_INTEROP_NONE)
|
|
return false;
|
|
|
|
if(kind!=MESA_INTEROP_NONE)
|
|
{
|
|
LogError("Error - MesaInterop Bind while already bound.");
|
|
return false;
|
|
}
|
|
|
|
void* glxinfo=dlsym(RTLD_DEFAULT, "MesaGLInteropGLXQueryDeviceInfo");
|
|
void* eglinfo=dlsym(RTLD_DEFAULT, "MesaGLInteropEGLQueryDeviceInfo");
|
|
|
|
if(((glxinfo!=GlxInfo) || (eglinfo!=EglInfo)) && (refCount!=0))
|
|
LogWarning("Warning - Mesa changed while holding interop contexts.");
|
|
|
|
GlxInfo=(PFNMESAGLINTEROPGLXQUERYDEVICEINFOPROC)glxinfo;
|
|
EglInfo=(PFNMESAGLINTEROPEGLQUERYDEVICEINFOPROC)eglinfo;
|
|
|
|
GlxExport=(PFNMESAGLINTEROPGLXEXPORTOBJECTPROC)dlsym(RTLD_DEFAULT, "MesaGLInteropGLXExportObject");
|
|
EglExport=(PFNMESAGLINTEROPEGLEXPORTOBJECTPROC)dlsym(RTLD_DEFAULT, "MesaGLInteropEGLExportObject");
|
|
|
|
uint32_t ret=MESA_INTEROP_NONE;
|
|
if(GlxInfo && GlxExport)
|
|
ret|=MESA_INTEROP_GLX;
|
|
if(EglInfo && EglExport)
|
|
ret|=MESA_INTEROP_EGL;
|
|
|
|
kind = MESA_INTEROP_KIND(ret & Kind);
|
|
display=Display;
|
|
context=Context;
|
|
|
|
if(kind!=MESA_INTEROP_NONE)
|
|
{
|
|
refCount++;
|
|
return true;
|
|
}
|
|
return false;
|
|
|
|
#endif
|
|
}
|
|
|
|
bool MesaInterop::GetInfo(mesa_glinterop_device_info& info) const
|
|
{
|
|
#ifdef _WIN32
|
|
return false;
|
|
#else
|
|
switch(kind)
|
|
{
|
|
case MESA_INTEROP_GLX:
|
|
return GlxInfo(display.glxDisplay, context.glxContext, &info)==MESA_GLINTEROP_SUCCESS;
|
|
case MESA_INTEROP_EGL:
|
|
return EglInfo(display.eglDisplay, context.eglContext, &info)==MESA_GLINTEROP_SUCCESS;
|
|
default:
|
|
return false;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
bool MesaInterop::Export (mesa_glinterop_export_in& in, mesa_glinterop_export_out& out) const
|
|
{
|
|
#ifdef _WIN32
|
|
return false;
|
|
#else
|
|
switch(kind)
|
|
{
|
|
case MESA_INTEROP_GLX:
|
|
return GlxExport(display.glxDisplay, context.glxContext, &in, &out)==MESA_GLINTEROP_SUCCESS;
|
|
case MESA_INTEROP_EGL:
|
|
return EglExport(display.eglDisplay, context.eglContext, &in, &out)==MESA_GLINTEROP_SUCCESS;
|
|
default:
|
|
return false;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
}
|
|
|
|
#endif // WITHOUT_HSA_BACKEND
|