From f768306d033c4594790764dbea858ff26dcdabec Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 10 Apr 2018 17:41:24 -0400 Subject: [PATCH] P4 to Git Change 1539198 by skudchad@skudchad_test2_win_opencl on 2018/04/10 17:32:14 SWDEV-145570 - [HIP] - Add HIP API skeletons for Peer and memory ReviewBoardURL = http://ocltc.amd.com/reviews/r/14596/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_context.cpp#7 edit ... //depot/stg/opencl/drivers/opencl/api/hip/hip_memory.cpp#9 edit ... //depot/stg/opencl/drivers/opencl/api/hip/hip_peer.cpp#1 add [ROCm/hip commit: 04decb72fcad4002caf80e6fee3236c56c5f2a44] --- projects/hip/api/hip/hip_context.cpp | 16 ++++ projects/hip/api/hip/hip_memory.cpp | 40 ++++------ projects/hip/api/hip/hip_peer.cpp | 109 +++++++++++++++++++++++++++ 3 files changed, 139 insertions(+), 26 deletions(-) create mode 100644 projects/hip/api/hip/hip_peer.cpp diff --git a/projects/hip/api/hip/hip_context.cpp b/projects/hip/api/hip/hip_context.cpp index 9bfe4ad45d..2e189f1351 100644 --- a/projects/hip/api/hip/hip_context.cpp +++ b/projects/hip/api/hip/hip_context.cpp @@ -169,6 +169,22 @@ hipError_t hipCtxPushCurrent(hipCtx_t ctx) { return hipSuccess; } +hipError_t hipDriverGetVersion(int* driverVersion) { + HIP_INIT_API(driverVersion); + + auto* deviceHandle = g_devices[0]->devices()[0]; + const auto& info = deviceHandle->info(); + + if (driverVersion) { + *driverVersion = AMD_PLATFORM_BUILD_NUMBER * 100 + + AMD_PLATFORM_REVISION_NUMBER; + } else { + return hipErrorInvalidValue; + } + + return hipSuccess;; +} + hipError_t hipCtxGetDevice(hipDevice_t* device) { HIP_INIT_API(device); diff --git a/projects/hip/api/hip/hip_memory.cpp b/projects/hip/api/hip/hip_memory.cpp index ef40bdbdf6..8cb51be08d 100644 --- a/projects/hip/api/hip/hip_memory.cpp +++ b/projects/hip/api/hip/hip_memory.cpp @@ -463,40 +463,28 @@ hipError_t hipIpcCloseMemHandle(void* devPtr) { return hipErrorUnknown; } -hipError_t hipMemcpyPeer(void* dst, hipCtx_t dstCtx, const void* src, hipCtx_t srcCtx, - size_t sizeBytes) { - HIP_INIT_API(dst, dstCtx, src, srcCtx, sizeBytes); +hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannelFormatKind f) { + hipChannelFormatDesc cd; + cd.x = x; + cd.y = y; + cd.z = z; + cd.w = w; + cd.f = f; + return cd; +} + +hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsigned flags) { + HIP_INIT_API(devicePointer, hostPointer, flags); assert(0 && "Unimplemented"); return hipErrorUnknown; } - -hipError_t hipMemcpyPeerAsync(void* dst, hipCtx_t dstDevice, const void* src, hipCtx_t srcDevice, - size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes, stream); +hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr) { + HIP_INIT_API(attributes, ptr); assert(0 && "Unimplemented"); return hipErrorUnknown; } - -hipError_t hipMemcpyPeer(void* dst, int dstDevice, const void* src, int srcDevice, - size_t sizeBytes) { - HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes); - - assert(0 && "Unimplemented"); - - return hipErrorUnknown; -} - -hipError_t hipMemcpyPeerAsync(void* dst, int dstDevice, const void* src, int srcDevice, - size_t sizeBytes, hipStream_t stream) { - HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes, stream); - - assert(0 && "Unimplemented"); - - return hipErrorUnknown; -} - diff --git a/projects/hip/api/hip/hip_peer.cpp b/projects/hip/api/hip/hip_peer.cpp new file mode 100644 index 0000000000..ad552e94b4 --- /dev/null +++ b/projects/hip/api/hip/hip_peer.cpp @@ -0,0 +1,109 @@ +/* +Copyright (c) 2015 - 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. +*/ + +#include + +#include "hip_internal.hpp" + +hipError_t hipDeviceCanAccessPeer(int* canAccessPeer, hipCtx_t thisCtx, hipCtx_t peerCtx) { + HIP_INIT_API(canAccessPeer, thisCtx, peerCtx); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipMemcpyPeer(void* dst, hipCtx_t dstCtx, const void* src, hipCtx_t srcCtx, + size_t sizeBytes) { + HIP_INIT_API(dst, dstCtx, src, srcCtx, sizeBytes); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipMemcpyPeerAsync(void* dst, hipCtx_t dstDevice, const void* src, hipCtx_t srcDevice, + size_t sizeBytes, hipStream_t stream) { + HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes, stream); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipDeviceCanAccessPeer(int* canAccessPeer, int deviceId, int peerDeviceId) { + HIP_INIT_API(canAccessPeer, deviceId, peerDeviceId); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipDeviceDisablePeerAccess(int peerDeviceId) { + HIP_INIT_API(peerDeviceId); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipDeviceEnablePeerAccess(int peerDeviceId, unsigned int flags) { + HIP_INIT_API(peerDeviceId, flags); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipMemcpyPeer(void* dst, int dstDevice, const void* src, int srcDevice, + size_t sizeBytes) { + HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipMemcpyPeerAsync(void* dst, int dstDevice, const void* src, int srcDevice, + size_t sizeBytes, hipStream_t stream) { + HIP_INIT_API(dst, dstDevice, src, srcDevice, sizeBytes, stream); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipCtxEnablePeerAccess(hipCtx_t peerCtx, unsigned int flags) { + HIP_INIT_API(peerCtx, flags); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} + +hipError_t hipCtxDisablePeerAccess(hipCtx_t peerCtx) { + HIP_INIT_API(peerCtx); + + assert(0 && "Unimplemented"); + + return hipErrorUnknown; +} \ No newline at end of file