From f932a51c8edc247f94089bcb7d01769e294b0816 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Wed, 25 Apr 2018 12:30:11 +0530 Subject: [PATCH] Fix gcc build issues for host code [ROCm/clr commit: 720e2093661b827bf8431a2bfa65c29d0f3fad16] --- .../include/hip/hcc_detail/driver_types.h | 52 ++++++++++--------- .../include/hip/hcc_detail/hip_runtime_api.h | 43 ++++----------- .../include/hip/hcc_detail/texture_types.h | 8 +-- .../clr/hipamd/include/hip/hip_runtime_api.h | 4 +- 4 files changed, 43 insertions(+), 64 deletions(-) diff --git a/projects/clr/hipamd/include/hip/hcc_detail/driver_types.h b/projects/clr/hipamd/include/hip/hcc_detail/driver_types.h index c25053ec32..661af64cd0 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/driver_types.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/driver_types.h @@ -23,27 +23,31 @@ THE SOFTWARE. #ifndef HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H #define HIP_INCLUDE_HIP_HCC_DETAIL_DRIVER_TYPES_H +#ifndef __cplusplus +#include +#endif + typedef void* hipDeviceptr_t; -enum hipChannelFormatKind { +typedef enum hipChannelFormatKind { hipChannelFormatKindSigned = 0, hipChannelFormatKindUnsigned = 1, hipChannelFormatKindFloat = 2, hipChannelFormatKindNone = 3 -}; +}hipChannelFormatKind; -struct hipChannelFormatDesc { +typedef struct hipChannelFormatDesc { int x; int y; int z; int w; enum hipChannelFormatKind f; -}; +}hipChannelFormatDesc; #define HIP_TRSF_NORMALIZED_COORDINATES 0x01 #define HIP_TRSF_READ_AS_INTEGER 0x00 #define HIP_TRSA_OVERRIDE_FORMAT 0x01 -enum hipArray_Format { +typedef enum hipArray_Format { HIP_AD_FORMAT_UNSIGNED_INT8 = 0x01, HIP_AD_FORMAT_UNSIGNED_INT16 = 0x02, HIP_AD_FORMAT_UNSIGNED_INT32 = 0x03, @@ -52,18 +56,18 @@ enum hipArray_Format { HIP_AD_FORMAT_SIGNED_INT32 = 0x0a, HIP_AD_FORMAT_HALF = 0x10, HIP_AD_FORMAT_FLOAT = 0x20 -}; +}hipArray_Format; -struct HIP_ARRAY_DESCRIPTOR { +typedef struct HIP_ARRAY_DESCRIPTOR { enum hipArray_Format format; unsigned int numChannels; size_t width; size_t height; unsigned int flags; size_t depth; -}; +}HIP_ARRAY_DESCRIPTOR; -struct hipArray { +typedef struct hipArray { void* data; // FIXME: generalize this struct hipChannelFormatDesc desc; unsigned int type; @@ -73,7 +77,7 @@ struct hipArray { struct HIP_ARRAY_DESCRIPTOR drvDesc; bool isDrv; unsigned int textureType; -}; +}hipArray; typedef struct hip_Memcpy2D { size_t height; @@ -115,17 +119,17 @@ typedef const struct hipMipmappedArray* hipMipmappedArray_const_t; /** * hip resource types */ -enum hipResourceType { +typedef enum hipResourceType { hipResourceTypeArray = 0x00, hipResourceTypeMipmappedArray = 0x01, hipResourceTypeLinear = 0x02, hipResourceTypePitch2D = 0x03 -}; +}hipResourceType; /** * hip texture resource view formats */ -enum hipResourceViewFormat { +typedef enum hipResourceViewFormat { hipResViewFormatNone = 0x00, hipResViewFormatUnsignedChar1 = 0x01, hipResViewFormatUnsignedChar2 = 0x02, @@ -161,12 +165,12 @@ enum hipResourceViewFormat { hipResViewFormatUnsignedBlockCompressed6H = 0x20, hipResViewFormatSignedBlockCompressed6H = 0x21, hipResViewFormatUnsignedBlockCompressed7 = 0x22 -}; +}hipResourceViewFormat; /** * HIP resource descriptor */ -struct hipResourceDesc { +typedef struct hipResourceDesc { enum hipResourceType resType; union { @@ -189,7 +193,7 @@ struct hipResourceDesc { size_t pitchInBytes; } pitch2D; } res; -}; +}hipResourceDesc; /** * hip resource view descriptor @@ -218,27 +222,27 @@ typedef enum hipMemcpyKind { 4 ///< Runtime will automatically determine copy-kind based on virtual addresses. } hipMemcpyKind; -struct hipPitchedPtr { +typedef struct hipPitchedPtr { void* ptr; size_t pitch; size_t xsize; size_t ysize; -}; +}hipPitchedPtr; -struct hipExtent { +typedef struct hipExtent { size_t width; // Width in elements when referring to array memory, in bytes when referring to // linear memory size_t height; size_t depth; -}; +}hipExtent; -struct hipPos { +typedef struct hipPos { size_t x; size_t y; size_t z; -}; +}hipPos; -struct hipMemcpy3DParms { +typedef struct hipMemcpy3DParms { hipArray_t srcArray; struct hipPos srcPos; struct hipPitchedPtr srcPtr; @@ -273,7 +277,7 @@ struct hipMemcpy3DParms { size_t srcXInBytes; size_t srcY; size_t srcZ; -}; +}hipMemcpy3DParms; static __inline__ struct hipPitchedPtr make_hipPitchedPtr(void* d, size_t p, size_t xsz, size_t ysz) { diff --git a/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h b/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h index 8674824c48..e78ccb02c4 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/hip_runtime_api.h @@ -30,7 +30,6 @@ THE SOFTWARE. */ #include #include -#include #ifndef GENERIC_GRID_LAUNCH #define GENERIC_GRID_LAUNCH 1 @@ -1314,7 +1313,7 @@ hipError_t hipMemcpyDtoDAsync(hipDeviceptr_t dst, hipDeviceptr_t src, size_t siz * hipMemcpyFromSymbolAsync */ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t sizeBytes, - size_t offset = 0, hipMemcpyKind kind = hipMemcpyHostToDevice); + size_t offset __dparm(0), hipMemcpyKind kind __dparm(hipMemcpyHostToDevice)); /** @@ -1343,13 +1342,13 @@ hipError_t hipMemcpyToSymbol(const void* symbolName, const void* src, size_t siz * hipMemcpyFromSymbolAsync */ hipError_t hipMemcpyToSymbolAsync(const void* symbolName, const void* src, size_t sizeBytes, - size_t offset, hipMemcpyKind kind, hipStream_t stream = 0); + size_t offset, hipMemcpyKind kind, hipStream_t stream __dparm(0)); hipError_t hipMemcpyFromSymbol(void* dst, const void* symbolName, size_t sizeBytes, - size_t offset = 0, hipMemcpyKind kind = hipMemcpyDeviceToHost); + size_t offset __dparm(0), hipMemcpyKind kind __dparm( hipMemcpyDeviceToHost )); hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t sizeBytes, - size_t offset, hipMemcpyKind kind, hipStream_t stream = 0); + size_t offset, hipMemcpyKind kind, hipStream_t stream __dparm(0)); /** * @brief Copy data from src to dst asynchronously. @@ -1379,13 +1378,8 @@ hipError_t hipMemcpyFromSymbolAsync(void* dst, const void* symbolName, size_t si * hipMemcpyFromArrayAsync, hipMemcpy2DFromArrayAsync, hipMemcpyToSymbolAsync, * hipMemcpyFromSymbolAsync */ -#if __cplusplus hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, - hipStream_t stream = 0); -#else -hipError_t hipMemcpyAsync(void* dst, const void* src, size_t sizeBytes, hipMemcpyKind kind, - hipStream_t stream); -#endif + hipStream_t stream __dparm(0)); /** * @brief Fills the first sizeBytes bytes of the memory area pointed to by dest with the constant @@ -1424,11 +1418,7 @@ hipError_t hipMemsetD8(hipDeviceptr_t dest, unsigned char value, size_t sizeByte * @param[in] stream - Stream identifier * @return #hipSuccess, #hipErrorInvalidValue, #hipErrorMemoryFree */ -#if __cplusplus -hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream = 0); -#else -hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream); -#endif +hipError_t hipMemsetAsync(void* dst, int value, size_t sizeBytes, hipStream_t stream __dparm(0)); /** * @brief Fills the memory area pointed to by dst with the constant value. @@ -1484,13 +1474,8 @@ hipError_t hipMemPtrGetInfo(void* ptr, size_t* size); * * @see hipMalloc, hipMallocPitch, hipFree, hipFreeArray, hipHostMalloc, hipHostFree */ -#if __cplusplus hipError_t hipMallocArray(hipArray** array, const hipChannelFormatDesc* desc, size_t width, - size_t height = 0, unsigned int flags = hipArrayDefault); -#else -hipError_t hipMallocArray(hipArray** array, const struct hipChannelFormatDesc* desc, size_t width, - size_t height, unsigned int flags); -#endif + size_t height __dparm(0), unsigned int flags __dparm(hipArrayDefault)); hipError_t hipArrayCreate(hipArray** pHandle, const HIP_ARRAY_DESCRIPTOR* pAllocateArray); hipError_t hipArray3DCreate(hipArray_t* array, const HIP_ARRAY_DESCRIPTOR* pAllocateArray); @@ -1558,13 +1543,8 @@ hipError_t hipMemcpyParam2D(const hip_Memcpy2D* pCopy); * @see hipMemcpy, hipMemcpyToArray, hipMemcpy2DToArray, hipMemcpyFromArray, hipMemcpyToSymbol, * hipMemcpyAsync */ -#if __cplusplus hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, - size_t height, hipMemcpyKind kind, hipStream_t stream = 0); -#else -hipError_t hipMemcpy2DAsync(void* dst, size_t dpitch, const void* src, size_t spitch, size_t width, - size_t height, hipMemcpyKind kind, hipStream_t stream); -#endif + size_t height, hipMemcpyKind kind, hipStream_t stream __dparm(0)); /** * @brief Copies data between host and device. @@ -1776,13 +1756,8 @@ hipError_t hipMemcpyPeer(void* dst, int dstDeviceId, const void* src, int srcDev * * @returns #hipSuccess, #hipErrorInvalidValue, #hipErrorInvalidDevice */ -#if __cplusplus hipError_t hipMemcpyPeerAsync(void* dst, int dstDeviceId, const void* src, int srcDevice, - size_t sizeBytes, hipStream_t stream = 0); -#else -hipError_t hipMemcpyPeerAsync(void* dst, int dstDevice, const void* src, int srcDevice, - size_t sizeBytes, hipStream_t stream); -#endif + size_t sizeBytes, hipStream_t stream __dparm(0)); #endif diff --git a/projects/clr/hipamd/include/hip/hcc_detail/texture_types.h b/projects/clr/hipamd/include/hip/hcc_detail/texture_types.h index 3d0d44bd55..bc334de248 100644 --- a/projects/clr/hipamd/include/hip/hcc_detail/texture_types.h +++ b/projects/clr/hipamd/include/hip/hcc_detail/texture_types.h @@ -70,7 +70,7 @@ enum hipTextureReadMode { hipReadModeElementType = 0, hipReadModeNormalizedFloat /** * hip texture reference */ -struct textureReference { +typedef struct textureReference { int normalized; enum hipTextureFilterMode filterMode; enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions @@ -85,12 +85,12 @@ struct textureReference { hipTextureObject_t textureObject; int numChannels; enum hipArray_Format format; -}; +}textureReference; /** * hip texture descriptor */ -struct hipTextureDesc { +typedef struct hipTextureDesc { enum hipTextureAddressMode addressMode[3]; // Texture address mode for up to 3 dimensions enum hipTextureFilterMode filterMode; enum hipTextureReadMode readMode; @@ -102,6 +102,6 @@ struct hipTextureDesc { float mipmapLevelBias; float minMipmapLevelClamp; float maxMipmapLevelClamp; -}; +}hipTextureDesc; #endif diff --git a/projects/clr/hipamd/include/hip/hip_runtime_api.h b/projects/clr/hipamd/include/hip/hip_runtime_api.h index 8d27724ad6..bfde2e942d 100644 --- a/projects/clr/hipamd/include/hip/hip_runtime_api.h +++ b/projects/clr/hipamd/include/hip/hip_runtime_api.h @@ -120,14 +120,14 @@ typedef struct hipDeviceProp_t { /** * Memory type (for pointer attributes) */ -enum hipMemoryType { +typedef enum hipMemoryType { hipMemoryTypeHost, ///< Memory is physically located on host hipMemoryTypeDevice, ///< Memory is physically located on device. (see deviceId for specific ///< device) hipMemoryTypeArray, ///< Array memory, physically located on device. (see deviceId for specific ///< device) hipMemoryTypeUnified ///< Not used currently -}; +}hipMemoryType; /**