ROCMOPS-1956 - Push restructured code to hipamd

hipamd will have AMD's ROCCLR based HIP backend implementation

Change-Id: Id7de9634519b4ce46fca71a1b61f3d5b1e3fc459


[ROCm/hipother commit: b2f4e62135]
Этот коммит содержится в:
Rahul Garg
2021-06-07 21:42:44 +00:00
родитель 7d8b728f8c
Коммит 62a54a9ad5
7 изменённых файлов: 2650 добавлений и 0 удалений
+28
Просмотреть файл
@@ -0,0 +1,28 @@
/*
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.
*/
#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_CHANNEL_DESCRIPTOR_H
#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_CHANNEL_DESCRIPTOR_H
#include "channel_descriptor.h"
#endif
+119
Просмотреть файл
@@ -0,0 +1,119 @@
/*
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.
*/
#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COMPLEX_H
#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COMPLEX_H
#include "cuComplex.h"
typedef cuFloatComplex hipFloatComplex;
__device__ __host__ static inline float hipCrealf(hipFloatComplex z) { return cuCrealf(z); }
__device__ __host__ static inline float hipCimagf(hipFloatComplex z) { return cuCimagf(z); }
__device__ __host__ static inline hipFloatComplex make_hipFloatComplex(float a, float b) {
return make_cuFloatComplex(a, b);
}
__device__ __host__ static inline hipFloatComplex hipConjf(hipFloatComplex z) { return cuConjf(z); }
__device__ __host__ static inline float hipCsqabsf(hipFloatComplex z) {
return cuCabsf(z) * cuCabsf(z);
}
__device__ __host__ static inline hipFloatComplex hipCaddf(hipFloatComplex p, hipFloatComplex q) {
return cuCaddf(p, q);
}
__device__ __host__ static inline hipFloatComplex hipCsubf(hipFloatComplex p, hipFloatComplex q) {
return cuCsubf(p, q);
}
__device__ __host__ static inline hipFloatComplex hipCmulf(hipFloatComplex p, hipFloatComplex q) {
return cuCmulf(p, q);
}
__device__ __host__ static inline hipFloatComplex hipCdivf(hipFloatComplex p, hipFloatComplex q) {
return cuCdivf(p, q);
}
__device__ __host__ static inline float hipCabsf(hipFloatComplex z) { return cuCabsf(z); }
typedef cuDoubleComplex hipDoubleComplex;
__device__ __host__ static inline double hipCreal(hipDoubleComplex z) { return cuCreal(z); }
__device__ __host__ static inline double hipCimag(hipDoubleComplex z) { return cuCimag(z); }
__device__ __host__ static inline hipDoubleComplex make_hipDoubleComplex(double a, double b) {
return make_cuDoubleComplex(a, b);
}
__device__ __host__ static inline hipDoubleComplex hipConj(hipDoubleComplex z) { return cuConj(z); }
__device__ __host__ static inline double hipCsqabs(hipDoubleComplex z) {
return cuCabs(z) * cuCabs(z);
}
__device__ __host__ static inline hipDoubleComplex hipCadd(hipDoubleComplex p, hipDoubleComplex q) {
return cuCadd(p, q);
}
__device__ __host__ static inline hipDoubleComplex hipCsub(hipDoubleComplex p, hipDoubleComplex q) {
return cuCsub(p, q);
}
__device__ __host__ static inline hipDoubleComplex hipCmul(hipDoubleComplex p, hipDoubleComplex q) {
return cuCmul(p, q);
}
__device__ __host__ static inline hipDoubleComplex hipCdiv(hipDoubleComplex p, hipDoubleComplex q) {
return cuCdiv(p, q);
}
__device__ __host__ static inline double hipCabs(hipDoubleComplex z) { return cuCabs(z); }
typedef cuFloatComplex hipComplex;
__device__ __host__ static inline hipComplex make_Complex(float x, float y) {
return make_cuComplex(x, y);
}
__device__ __host__ static inline hipFloatComplex hipComplexDoubleToFloat(hipDoubleComplex z) {
return cuComplexDoubleToFloat(z);
}
__device__ __host__ static inline hipDoubleComplex hipComplexFloatToDouble(hipFloatComplex z) {
return cuComplexFloatToDouble(z);
}
__device__ __host__ static inline hipComplex hipCfmaf(hipComplex p, hipComplex q, hipComplex r) {
return cuCfmaf(p, q, r);
}
__device__ __host__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDoubleComplex q,
hipDoubleComplex r) {
return cuCfma(p, q, r);
}
#endif
+12
Просмотреть файл
@@ -0,0 +1,12 @@
#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COOPERATIVE_GROUPS_H
#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COOPERATIVE_GROUPS_H
// Include CUDA headers
#include <cuda_runtime.h>
#include <cooperative_groups.h>
// Include HIP wrapper headers around CUDA
#include <hip/hip_runtime.h>
#include <hip/hip_runtime_api.h>
#endif // HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_COOPERATIVE_GROUPS_H
+122
Просмотреть файл
@@ -0,0 +1,122 @@
/*
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.
*/
#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_H
#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_RUNTIME_H
#include <cuda_runtime.h>
#include <hip/hip_runtime_api.h>
#define HIP_KERNEL_NAME(...) __VA_ARGS__
typedef int hipLaunchParm;
#define hipLaunchKernelGGLInternal(kernelName, numBlocks, numThreads, memPerBlock, streamId, ...) \
do { \
kernelName<<<numBlocks, numThreads, memPerBlock, streamId>>>(__VA_ARGS__); \
} while (0)
#define hipLaunchKernelGGL(kernelName, ...) hipLaunchKernelGGLInternal((kernelName), __VA_ARGS__)
#define hipReadModeElementType cudaReadModeElementType
#ifdef __CUDA_ARCH__
// 32-bit Atomics:
#define __HIP_ARCH_HAS_GLOBAL_INT32_ATOMICS__ (__CUDA_ARCH__ >= 110)
#define __HIP_ARCH_HAS_GLOBAL_FLOAT_ATOMIC_EXCH__ (__CUDA_ARCH__ >= 110)
#define __HIP_ARCH_HAS_SHARED_INT32_ATOMICS__ (__CUDA_ARCH__ >= 120)
#define __HIP_ARCH_HAS_SHARED_FLOAT_ATOMIC_EXCH__ (__CUDA_ARCH__ >= 120)
#define __HIP_ARCH_HAS_FLOAT_ATOMIC_ADD__ (__CUDA_ARCH__ >= 200)
// 64-bit Atomics:
#define __HIP_ARCH_HAS_GLOBAL_INT64_ATOMICS__ (__CUDA_ARCH__ >= 200)
#define __HIP_ARCH_HAS_SHARED_INT64_ATOMICS__ (__CUDA_ARCH__ >= 120)
// Doubles
#define __HIP_ARCH_HAS_DOUBLES__ (__CUDA_ARCH__ >= 120)
// warp cross-lane operations:
#define __HIP_ARCH_HAS_WARP_VOTE__ (__CUDA_ARCH__ >= 120)
#define __HIP_ARCH_HAS_WARP_BALLOT__ (__CUDA_ARCH__ >= 200)
#define __HIP_ARCH_HAS_WARP_SHUFFLE__ (__CUDA_ARCH__ >= 300)
#define __HIP_ARCH_HAS_WARP_FUNNEL_SHIFT__ (__CUDA_ARCH__ >= 350)
// sync
#define __HIP_ARCH_HAS_THREAD_FENCE_SYSTEM__ (__CUDA_ARCH__ >= 200)
#define __HIP_ARCH_HAS_SYNC_THREAD_EXT__ (__CUDA_ARCH__ >= 200)
// misc
#define __HIP_ARCH_HAS_SURFACE_FUNCS__ (__CUDA_ARCH__ >= 200)
#define __HIP_ARCH_HAS_3DGRID__ (__CUDA_ARCH__ >= 200)
#define __HIP_ARCH_HAS_DYNAMIC_PARALLEL__ (__CUDA_ARCH__ >= 350)
#endif
#ifdef __CUDACC__
#define hipThreadIdx_x threadIdx.x
#define hipThreadIdx_y threadIdx.y
#define hipThreadIdx_z threadIdx.z
#define hipBlockIdx_x blockIdx.x
#define hipBlockIdx_y blockIdx.y
#define hipBlockIdx_z blockIdx.z
#define hipBlockDim_x blockDim.x
#define hipBlockDim_y blockDim.y
#define hipBlockDim_z blockDim.z
#define hipGridDim_x gridDim.x
#define hipGridDim_y gridDim.y
#define hipGridDim_z gridDim.z
#define HIP_SYMBOL(X) &X
/**
* Map HIP_DYNAMIC_SHARED to "extern __shared__" for compatibility with old HIP applications
* To be removed in a future release.
*/
#define HIP_DYNAMIC_SHARED(type, var) extern __shared__ type var[];
#define HIP_DYNAMIC_SHARED_ATTRIBUTE
#ifdef __HIP_DEVICE_COMPILE__
#define abort_() \
{ asm("trap;"); }
#undef assert
#define assert(COND) \
{ \
if (!COND) { \
abort_(); \
} \
}
#endif
#define __clock() clock()
#define __clock64() clock64()
#endif
#endif
Разница между файлами не показана из-за своего большого размера Загрузить разницу
+6
Просмотреть файл
@@ -0,0 +1,6 @@
#ifndef HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_TEXTURE_TYPES_H
#define HIP_INCLUDE_HIP_NVIDIA_DETAIL_HIP_TEXTURE_TYPES_H
#include <texture_types.h>
#endif
+168
Просмотреть файл
@@ -0,0 +1,168 @@
/*
Copyright (c) 2021 - 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 HIPRTC_H
#define HIPRTC_H
#include <cuda.h>
#include <nvrtc.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <stdlib.h>
#if !defined(_WIN32)
#pragma GCC visibility push(default)
#endif
typedef enum hiprtcResult {
HIPRTC_SUCCESS = 0,
HIPRTC_ERROR_OUT_OF_MEMORY = 1,
HIPRTC_ERROR_PROGRAM_CREATION_FAILURE = 2,
HIPRTC_ERROR_INVALID_INPUT = 3,
HIPRTC_ERROR_INVALID_PROGRAM = 4,
HIPRTC_ERROR_INVALID_OPTION = 5,
HIPRTC_ERROR_COMPILATION = 6,
HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE = 7,
HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION = 8,
HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION = 9,
HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID = 10,
HIPRTC_ERROR_INTERNAL_ERROR = 11
} hiprtcResult;
inline static nvrtcResult hiprtcResultTonvrtcResult(hiprtcResult result) {
switch (result) {
case HIPRTC_SUCCESS:
return NVRTC_SUCCESS;
case HIPRTC_ERROR_OUT_OF_MEMORY:
return NVRTC_ERROR_OUT_OF_MEMORY;
case HIPRTC_ERROR_PROGRAM_CREATION_FAILURE:
return NVRTC_ERROR_PROGRAM_CREATION_FAILURE;
case HIPRTC_ERROR_INVALID_INPUT:
return NVRTC_ERROR_INVALID_INPUT;
case HIPRTC_ERROR_INVALID_PROGRAM:
return NVRTC_ERROR_INVALID_PROGRAM;
case HIPRTC_ERROR_INVALID_OPTION:
return NVRTC_ERROR_INVALID_OPTION;
case HIPRTC_ERROR_COMPILATION:
return NVRTC_ERROR_COMPILATION;
case HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE:
return NVRTC_ERROR_BUILTIN_OPERATION_FAILURE;
case HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION:
return NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION;
case HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION:
return NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION;
case HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID:
return NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID;
case HIPRTC_ERROR_INTERNAL_ERROR:
return NVRTC_ERROR_INTERNAL_ERROR;
}
}
inline static hiprtcResult nvrtcResultTohiprtcResult(nvrtcResult result) {
switch (result) {
case NVRTC_SUCCESS:
return HIPRTC_SUCCESS;
case NVRTC_ERROR_OUT_OF_MEMORY:
return HIPRTC_ERROR_OUT_OF_MEMORY;
case NVRTC_ERROR_PROGRAM_CREATION_FAILURE:
return HIPRTC_ERROR_PROGRAM_CREATION_FAILURE;
case NVRTC_ERROR_INVALID_INPUT:
return HIPRTC_ERROR_INVALID_INPUT;
case NVRTC_ERROR_INVALID_PROGRAM:
return HIPRTC_ERROR_INVALID_PROGRAM;
case NVRTC_ERROR_INVALID_OPTION:
return HIPRTC_ERROR_INVALID_OPTION;
case NVRTC_ERROR_COMPILATION:
return HIPRTC_ERROR_COMPILATION;
case NVRTC_ERROR_BUILTIN_OPERATION_FAILURE:
return HIPRTC_ERROR_BUILTIN_OPERATION_FAILURE;
case NVRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION:
return HIPRTC_ERROR_NO_NAME_EXPRESSIONS_AFTER_COMPILATION;
case NVRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION:
return HIPRTC_ERROR_NO_LOWERED_NAMES_BEFORE_COMPILATION;
case NVRTC_ERROR_NAME_EXPRESSION_NOT_VALID:
return HIPRTC_ERROR_NAME_EXPRESSION_NOT_VALID;
case NVRTC_ERROR_INTERNAL_ERROR:
return HIPRTC_ERROR_INTERNAL_ERROR;
}
}
const char* hiprtcGetErrorString(hiprtcResult result) {
return nvrtcGetErrorString(hiprtcResultTonvrtcResult(result));
}
hiprtcResult hiprtcVersion(int* major, int* minor) {
return nvrtcResultTohiprtcResult(nvrtcVersion(major, minor));
}
typedef nvrtcProgram hiprtcProgram;
hiprtcResult hiprtcAddNameExpression(hiprtcProgram prog, const char* name_expression) {
return nvrtcResultTohiprtcResult(nvrtcAddNameExpression(prog, name_expression));
}
hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char** options) {
return nvrtcResultTohiprtcResult(nvrtcCompileProgram(prog, numOptions, options));
}
hiprtcResult hiprtcCreateProgram(hiprtcProgram* prog, const char* src, const char* name,
int numHeaders, const char** headers, const char** includeNames) {
return nvrtcResultTohiprtcResult(
nvrtcCreateProgram(prog, src, name, numHeaders, headers, includeNames));
}
hiprtcResult hiprtcDestroyProgram(hiprtcProgram* prog) {
return nvrtcResultTohiprtcResult(nvrtcDestroyProgram(prog));
}
hiprtcResult hiprtcGetLoweredName(hiprtcProgram prog, const char* name_expression,
const char** lowered_name) {
return nvrtcResultTohiprtcResult(nvrtcGetLoweredName(prog, name_expression, lowered_name));
}
hiprtcResult hiprtcGetProgramLog(hiprtcProgram prog, char* log) {
return nvrtcResultTohiprtcResult(nvrtcGetProgramLog(prog, log));
}
hiprtcResult hiprtcGetProgramLogSize(hiprtcProgram prog, size_t* logSizeRet) {
return nvrtcResultTohiprtcResult(nvrtcGetProgramLogSize(prog, logSizeRet));
}
hiprtcResult hiprtcGetCode(hiprtcProgram prog, char* code) {
return nvrtcResultTohiprtcResult(nvrtcGetPTX(prog, code));
}
hiprtcResult hiprtcGetCodeSize(hiprtcProgram prog, size_t* codeSizeRet) {
return nvrtcResultTohiprtcResult(nvrtcGetPTXSize(prog, codeSizeRet));
}
#if !defined(_WIN32)
#pragma GCC visibility pop
#endif
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // HIPRTC_H