2
0

P4 to Git Change 2061101 by skudchad@skudchad_test2_win_opencl on 2020/01/21 16:47:25

SWDEV-219917 - [VDI Cleanup] Remove some direct OpenCL references, introduce a common functionality.

	ReviewBoardURL = http://ocltc.amd.com/reviews/r/18488/diff/

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/hip/build/Makefile.hip#30 edit
... //depot/stg/opencl/drivers/opencl/api/hip/fixme.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hip_internal.hpp#51 edit
... //depot/stg/opencl/drivers/opencl/api/hip/hiprtc_internal.hpp#3 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/build/Makefile.api#190 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_common.hpp#25 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_context.cpp#61 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_device.cpp#75 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_execute.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_icd.cpp#36 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_platform_amd.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_program.cpp#54 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#610 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#180 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#150 edit
... //depot/stg/opencl/drivers/opencl/runtime/include/vdi_agent_amd.h#1 add
... //depot/stg/opencl/drivers/opencl/runtime/include/vdi_common.hpp#1 add
... //depot/stg/opencl/drivers/opencl/runtime/os/os.hpp#32 edit
... //depot/stg/opencl/drivers/opencl/runtime/os/os_posix.cpp#49 edit
... //depot/stg/opencl/drivers/opencl/runtime/os/os_win32.cpp#50 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/agent.cpp#9 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/agent.hpp#7 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.cpp#54 edit
... //depot/stg/opencl/drivers/opencl/runtime/runtimedefs#54 edit
Este cometimento está contido em:
foreman
2020-01-21 16:52:40 -05:00
ascendente 69884318ac
cometimento 29dd0eb7a2
11 ficheiros modificados com 397 adições e 295 eliminações
+171
Ver ficheiro
@@ -0,0 +1,171 @@
//
// Copyright (c) 2010 Advanced Micro Devices, Inc. All rights reserved.
//
#ifndef _VDI_AGENT_AMD_H
#define _VDI_AGENT_AMD_H
#include <CL/cl.h>
#include "amdocl/cl_icd_amd.h"
#define cl_amd_agent 1
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef const struct _vdi_agent vdi_agent;
#define VDI_AGENT_VERSION_1_0 100
/* Context Callbacks */
typedef void(CL_CALLBACK* acContextCreate_fn)(vdi_agent* /* agent */, cl_context /* context */);
typedef void(CL_CALLBACK* acContextFree_fn)(vdi_agent* /* agent */, cl_context /* context */);
/* Command Queue Callbacks */
typedef void(CL_CALLBACK* acCommandQueueCreate_fn)(vdi_agent* /* agent */,
cl_command_queue /* queue */);
typedef void(CL_CALLBACK* acCommandQueueFree_fn)(vdi_agent* /* agent */,
cl_command_queue /* queue */);
/* Event Callbacks */
typedef void(CL_CALLBACK* acEventCreate_fn)(vdi_agent* /* agent */, cl_event /* event */,
cl_command_type /* type */);
typedef void(CL_CALLBACK* acEventFree_fn)(vdi_agent* /* agent */, cl_event /* event */);
typedef void(CL_CALLBACK* acEventStatusChanged_fn)(vdi_agent* /* agent */, cl_event /* event */,
cl_int /* execution_status */,
cl_long /* epoch_time_stamp */);
/* Memory Object Callbacks */
typedef void(CL_CALLBACK* acMemObjectCreate_fn)(vdi_agent* /* agent */, cl_mem /* memobj */);
typedef void(CL_CALLBACK* acMemObjectFree_fn)(vdi_agent* /* agent */, cl_mem /* memobj */);
typedef void(CL_CALLBACK* acMemObjectAcquired_fn)(vdi_agent* /* agent */, cl_mem /* memobj */,
cl_device_id /* device */,
cl_long /* elapsed_time */);
/* Sampler Callbacks */
typedef void(CL_CALLBACK* acSamplerCreate_fn)(vdi_agent* /* agent */, cl_sampler /* sampler */);
typedef void(CL_CALLBACK* acSamplerFree_fn)(vdi_agent* /* agent */, cl_sampler /* sampler */);
/* Program Callbacks */
typedef void(CL_CALLBACK* acProgramCreate_fn)(vdi_agent* /* agent */, cl_program /* program */);
typedef void(CL_CALLBACK* acProgramFree_fn)(vdi_agent* /* agent */, cl_program /* program */);
typedef void(CL_CALLBACK* acProgramBuild_fn)(vdi_agent* /* agent */, cl_program /* program */);
/* Kernel Callbacks */
typedef void(CL_CALLBACK* acKernelCreate_fn)(vdi_agent* /* agent */, cl_kernel /* kernel */);
typedef void(CL_CALLBACK* acKernelFree_fn)(vdi_agent* /* agent */, cl_kernel /* kernel */);
typedef void(CL_CALLBACK* acKernelSetArg_fn)(vdi_agent* /* agent */, cl_kernel /* kernel */,
cl_int /* arg_index */, size_t /* size */,
const void* /* value_ptr */);
typedef struct _vdi_agent_callbacks {
/* Context Callbacks */
acContextCreate_fn ContextCreate;
acContextFree_fn ContextFree;
/* Command Queue Callbacks */
acCommandQueueCreate_fn CommandQueueCreate;
acCommandQueueFree_fn CommandQueueFree;
/* Event Callbacks */
acEventCreate_fn EventCreate;
acEventFree_fn EventFree;
acEventStatusChanged_fn EventStatusChanged;
/* Memory Object Callbacks */
acMemObjectCreate_fn MemObjectCreate;
acMemObjectFree_fn MemObjectFree;
acMemObjectAcquired_fn MemObjectAcquired;
/* Sampler Callbacks */
acSamplerCreate_fn SamplerCreate;
acSamplerFree_fn SamplerFree;
/* Program Callbacks */
acProgramCreate_fn ProgramCreate;
acProgramFree_fn ProgramFree;
acProgramBuild_fn ProgramBuild;
/* Kernel Callbacks */
acKernelCreate_fn KernelCreate;
acKernelFree_fn KernelFree;
acKernelSetArg_fn KernelSetArg;
} vdi_agent_callbacks;
typedef cl_uint vdi_agent_capability_action;
#define VDI_AGENT_ADD_CAPABILITIES 0x0
#define VDI_AGENT_RELINQUISH_CAPABILITIES 0x1
typedef struct _vdi_agent_capabilities {
cl_bitfield canGenerateContextEvents : 1;
cl_bitfield canGenerateCommandQueueEvents : 1;
cl_bitfield canGenerateEventEvents : 1;
cl_bitfield canGenerateMemObjectEvents : 1;
cl_bitfield canGenerateSamplerEvents : 1;
cl_bitfield canGenerateProgramEvents : 1;
cl_bitfield canGenerateKernelEvents : 1;
} vdi_agent_capabilities;
struct _vdi_agent {
cl_int(CL_API_CALL* GetVersionNumber)(vdi_agent* /* agent */, cl_int* /* version_ret */);
cl_int(CL_API_CALL* GetPlatform)(vdi_agent* /* agent */, cl_platform_id* /* platform_id_ret */);
cl_int(CL_API_CALL* GetTime)(vdi_agent* /* agent */, cl_long* /* time_nanos */);
cl_int(CL_API_CALL* SetCallbacks)(vdi_agent* /* agent */,
const vdi_agent_callbacks* /* callbacks */, size_t /* size */);
cl_int(CL_API_CALL* GetPotentialCapabilities)(vdi_agent* /* agent */,
vdi_agent_capabilities* /* capabilities */);
cl_int(CL_API_CALL* GetCapabilities)(vdi_agent* /* agent */,
vdi_agent_capabilities* /* capabilities */);
cl_int(CL_API_CALL* SetCapabilities)(vdi_agent* /* agent */,
const vdi_agent_capabilities* /* capabilities */,
vdi_agent_capability_action /* action */);
cl_int(CL_API_CALL* GetICDDispatchTable)(vdi_agent* /* agent */,
cl_icd_dispatch_table* /* table */, size_t /* size */);
cl_int(CL_API_CALL* SetICDDispatchTable)(vdi_agent* /* agent */,
const cl_icd_dispatch_table* /* table */,
size_t /* size */);
/* add Kernel/Program helper functions, etc... */
};
extern cl_int CL_CALLBACK vdiAgent_OnLoad(vdi_agent* /* agent */);
extern void CL_CALLBACK vdiAgent_OnUnload(vdi_agent* /* agent */);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _VDI_AGENT_AMD_H */
+164
Ver ficheiro
@@ -0,0 +1,164 @@
/*
Copyright (c) 2020 - present Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef VDI_COMMON_HPP_
#define VDI_COMMON_HPP_
#include "top.hpp"
#include "platform/runtime.hpp"
#include "platform/command.hpp"
#include "platform/memory.hpp"
#include "thread/thread.hpp"
#include "platform/commandqueue.hpp"
#include <vector>
#include <utility>
//! \cond ignore
namespace amd {
template <typename T>
class NotNullWrapper
{
private:
T* const ptrOrNull_;
protected:
explicit NotNullWrapper(T* ptrOrNull)
: ptrOrNull_(ptrOrNull)
{ }
public:
void operator = (T value) const
{
if (ptrOrNull_ != NULL) {
*ptrOrNull_ = value;
}
}
};
template <typename T>
class NotNullReference : protected NotNullWrapper<T>
{
public:
explicit NotNullReference(T* ptrOrNull)
: NotNullWrapper<T>(ptrOrNull)
{ }
const NotNullWrapper<T>& operator * () const { return *this; }
};
} // namespace amd
template <typename T>
inline amd::NotNullReference<T>
not_null(T* ptrOrNull)
{
return amd::NotNullReference<T>(ptrOrNull);
}
#define VDI_CHECK_THREAD(thread) \
(thread != NULL || ((thread = new amd::HostThread()) != NULL \
&& thread == amd::Thread::current()))
#define RUNTIME_ENTRY_RET(ret, func, args) \
CL_API_ENTRY ret CL_API_CALL \
func args \
{ \
amd::Thread* thread = amd::Thread::current(); \
if (!VDI_CHECK_THREAD(thread)) { \
*not_null(errcode_ret) = CL_OUT_OF_HOST_MEMORY; \
return (ret) 0; \
}
#define RUNTIME_ENTRY_RET_NOERRCODE(ret, func, args) \
CL_API_ENTRY ret CL_API_CALL \
func args \
{ \
amd::Thread* thread = amd::Thread::current(); \
if (!VDI_CHECK_THREAD(thread)) { \
return (ret) 0; \
}
#define RUNTIME_ENTRY(ret, func, args) \
CL_API_ENTRY ret CL_API_CALL \
func args \
{ \
amd::Thread* thread = amd::Thread::current(); \
if (!VDI_CHECK_THREAD(thread)) { \
return CL_OUT_OF_HOST_MEMORY; \
}
#define RUNTIME_ENTRY_VOID(ret, func, args) \
CL_API_ENTRY ret CL_API_CALL \
func args \
{ \
amd::Thread* thread = amd::Thread::current(); \
if (!VDI_CHECK_THREAD(thread)) { \
return; \
}
#define RUNTIME_EXIT \
/* FIXME_lmoriche: we should check to thread->lastError here! */ \
}
namespace amd {
namespace detail {
template <typename T>
struct ParamInfo
{
static inline std::pair<const void*, size_t> get(const T& param) {
return std::pair<const void*, size_t>(&param, sizeof(T));
}
};
template <>
struct ParamInfo<const char*>
{
static inline std::pair<const void*, size_t> get(const char* param) {
return std::pair<const void*, size_t>(param, strlen(param) + 1);
}
};
template <int N>
struct ParamInfo<char[N]>
{
static inline std::pair<const void*, size_t> get(const char* param) {
return std::pair<const void*, size_t>(param, strlen(param) + 1);
}
};
} // namespace detail
struct PlatformIDS { const struct KHRicdVendorDispatchRec* dispatch_; };
class PlatformID {
public:
static PlatformIDS Platform;
};
#define AMD_PLATFORM (reinterpret_cast<cl_platform_id>(&amd::PlatformID::Platform))
} // namespace amd
#endif /* _VDI_COMMON_H */