Merge branch 'master' into getsymboladdress

[ROCm/hip commit: 8610128c3e]
This commit is contained in:
Michael Kuron
2018-11-20 12:03:22 +01:00
committed by GitHub
31 changed files with 1349 additions and 580 deletions
@@ -51,6 +51,8 @@ const std::map<llvm::StringRef, hipCounter>& CUDA_RENAMES_MAP() {
ret.insert(CUDA_DRIVER_FUNCTION_MAP.begin(), CUDA_DRIVER_FUNCTION_MAP.end());
ret.insert(CUDA_RUNTIME_TYPE_NAME_MAP.begin(), CUDA_RUNTIME_TYPE_NAME_MAP.end());
ret.insert(CUDA_RUNTIME_FUNCTION_MAP.begin(), CUDA_RUNTIME_FUNCTION_MAP.end());
ret.insert(CUDA_COMPLEX_TYPE_NAME_MAP.begin(), CUDA_COMPLEX_TYPE_NAME_MAP.end());
ret.insert(CUDA_COMPLEX_FUNCTION_MAP.begin(), CUDA_COMPLEX_FUNCTION_MAP.end());
ret.insert(CUDA_BLAS_TYPE_NAME_MAP.begin(), CUDA_BLAS_TYPE_NAME_MAP.end());
ret.insert(CUDA_BLAS_FUNCTION_MAP.begin(), CUDA_BLAS_FUNCTION_MAP.end());
ret.insert(CUDA_RAND_TYPE_NAME_MAP.begin(), CUDA_RAND_TYPE_NAME_MAP.end());
+4
View File
@@ -15,6 +15,10 @@ extern const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_TYPE_NAME_MAP;
extern const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_FUNCTION_MAP;
// Maps the names of CUDA RUNTIME API types to the corresponding HIP types
extern const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_TYPE_NAME_MAP;
// Maps the names of CUDA Complex API types to the corresponding HIP types
extern const std::map<llvm::StringRef, hipCounter> CUDA_COMPLEX_TYPE_NAME_MAP;
// Maps the names of CUDA Complex API functions to the corresponding HIP functions
extern const std::map<llvm::StringRef, hipCounter> CUDA_COMPLEX_FUNCTION_MAP;
// Maps the names of CUDA RUNTIME API functions to the corresponding HIP functions
extern const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP;
// Maps the names of CUDA BLAS API types to the corresponding HIP types
@@ -0,0 +1,28 @@
#include "CUDA2HIP.h"
// Maps the names of CUDA DRIVER API types to the corresponding HIP types
const std::map<llvm::StringRef, hipCounter> CUDA_COMPLEX_FUNCTION_MAP{
{"cuCrealf", {"hipCrealf", CONV_COMPLEX, API_COMPLEX}},
{"cuCimagf", {"hipCimagf", CONV_COMPLEX, API_COMPLEX}},
{"make_cuFloatComplex", {"make_hipFloatComplex", CONV_COMPLEX, API_COMPLEX}},
{"cuConjf", {"hipConjf", CONV_COMPLEX, API_COMPLEX}},
{"cuCaddf", {"hipCaddf", CONV_COMPLEX, API_COMPLEX}},
{"cuCsubf", {"hipCsubf", CONV_COMPLEX, API_COMPLEX}},
{"cuCmulf", {"hipCmulf", CONV_COMPLEX, API_COMPLEX}},
{"cuCdivf", {"hipCdivf", CONV_COMPLEX, API_COMPLEX}},
{"cuCabsf", {"hipCabsf", CONV_COMPLEX, API_COMPLEX}},
{"cuCreal", {"hipCreal", CONV_COMPLEX, API_COMPLEX}},
{"cuCimag", {"hipCimag", CONV_COMPLEX, API_COMPLEX}},
{"make_cuDoubleComplex", {"make_hipDoubleComplex", CONV_COMPLEX, API_COMPLEX}},
{"cuConj", {"hipConj", CONV_COMPLEX, API_COMPLEX}},
{"cuCadd", {"hipCadd", CONV_COMPLEX, API_COMPLEX}},
{"cuCsub", {"hipCsub", CONV_COMPLEX, API_COMPLEX}},
{"cuCmul", {"hipCmul", CONV_COMPLEX, API_COMPLEX}},
{"cuCdiv", {"hipCdiv", CONV_COMPLEX, API_COMPLEX}},
{"cuCabs", {"hipCabs", CONV_COMPLEX, API_COMPLEX}},
{"make_cuComplex", {"make_hipComplex", CONV_COMPLEX, API_COMPLEX}},
{"cuComplexFloatToDouble", {"hipComplexFloatToDouble", CONV_COMPLEX, API_COMPLEX}},
{"cuComplexDoubleToFloat", {"hipComplexDoubleToFloat", CONV_COMPLEX, API_COMPLEX}},
{"cuCfmaf", {"hipCfmaf", CONV_COMPLEX, API_COMPLEX}},
{"cuCfma", {"hipCfma", CONV_COMPLEX, API_COMPLEX}},
};
@@ -0,0 +1,8 @@
#include "CUDA2HIP.h"
// Maps the names of CUDA DRIVER API types to the corresponding HIP types
const std::map<llvm::StringRef, hipCounter> CUDA_COMPLEX_TYPE_NAME_MAP{
{"cuFloatComplex", {"hipFloatComplex", CONV_TYPE, API_COMPLEX}},
{"cuDoubleComplex", {"hipDoubleComplex", CONV_TYPE, API_COMPLEX}},
{"cuComplex", {"hipComplex", CONV_TYPE, API_COMPLEX}},
};
File diff suppressed because it is too large Load Diff
@@ -80,8 +80,10 @@ const std::map<llvm::StringRef, hipCounter> CUDA_DRIVER_TYPE_NAME_MAP{
{"CUDA_TEXTURE_DESC_st", {"HIP_TEXTURE_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
{"CUDA_TEXTURE_DESC", {"HIP_TEXTURE_DESC", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
{"CUdevprop_st", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}},
{"CUdevprop", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER}},
// no analogue
// NOTE: cudaDeviceProp differs
{"CUdevprop_st", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
{"CUdevprop", {"hipDeviceProp_t", CONV_TYPE, API_DRIVER, HIP_UNSUPPORTED}},
// cudaIpcEventHandle_st
{"CUipcEventHandle_st", {"ihipIpcEventHandle_t", CONV_TYPE, API_DRIVER}},
@@ -1,6 +1,6 @@
#include "CUDA2HIP.h"
// Map of all functions
// Map of all CUDA Runtime API functions
const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
// Error API
{"cudaGetLastError", {"hipGetLastError", CONV_ERROR, API_RUNTIME}},
@@ -9,29 +9,49 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"cudaGetErrorString", {"hipGetErrorString", CONV_ERROR, API_RUNTIME}},
// memcpy functions
// no analogue
// NOTE: Not equal to cuMemcpy due to different signatures
{"cudaMemcpy", {"hipMemcpy", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyToArray", {"hipMemcpyToArray", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyToSymbol", {"hipMemcpyToSymbol", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyToSymbolAsync", {"hipMemcpyToSymbolAsync", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyAsync", {"hipMemcpyAsync", CONV_MEMORY, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuMemcpy2D due to different signatures
{"cudaMemcpy2D", {"hipMemcpy2D", CONV_MEMORY, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuMemcpy2DAsync due to different signatures
{"cudaMemcpy2DAsync", {"hipMemcpy2DAsync", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpy2DToArray", {"hipMemcpy2DToArray", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpy2DArrayToArray", {"hipMemcpy2DArrayToArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpy2DFromArray", {"hipMemcpy2DFromArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpy2DFromArrayAsync", {"hipMemcpy2DFromArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpy2DToArrayAsync", {"hipMemcpy2DToArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMemcpy3D due to different signatures
{"cudaMemcpy3D", {"hipMemcpy3D", CONV_MEMORY, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuMemcpy3DAsync due to different signatures
{"cudaMemcpy3DAsync", {"hipMemcpy3DAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMemcpy3DPeer due to different signatures
{"cudaMemcpy3DPeer", {"hipMemcpy3DPeer", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMemcpy3DPeerAsync due to different signatures
{"cudaMemcpy3DPeerAsync", {"hipMemcpy3DPeerAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMemcpyAtoA due to different signatures
{"cudaMemcpyArrayToArray", {"hipMemcpyArrayToArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpyFromArrayAsync", {"hipMemcpyFromArrayAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMemcpyFromSymbol", {"hipMemcpyFromSymbol", CONV_MEMORY, API_RUNTIME}},
{"cudaMemcpyFromSymbolAsync", {"hipMemcpyFromSymbolAsync", CONV_MEMORY, API_RUNTIME}},
{"cudaMemAdvise", {"hipMemAdvise", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, //
{"cudaMemRangeGetAttribute", {"hipMemRangeGetAttribute", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, //
{"cudaMemRangeGetAttributes", {"hipMemRangeGetAttributes", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, //
// cuMemAdvise
{"cudaMemAdvise", {"hipMemAdvise", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// cuMemRangeGetAttribute
{"cudaMemRangeGetAttribute", {"hipMemRangeGetAttribute", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// cuMemRangeGetAttributes
{"cudaMemRangeGetAttributes", {"hipMemRangeGetAttributes", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// memset
{"cudaMemset", {"hipMemset", CONV_MEMORY, API_RUNTIME}},
@@ -42,13 +62,17 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"cudaMemset3DAsync", {"hipMemset3DAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// Memory management
// cuMemGetInfo
{"cudaMemGetInfo", {"hipMemGetInfo", CONV_MEMORY, API_RUNTIME}},
{"cudaArrayGetInfo", {"hipArrayGetInfo", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMipmappedArrayDestroy due to different signatures
{"cudaFreeMipmappedArray", {"hipFreeMipmappedArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaGetMipmappedArrayLevel", {"hipGetMipmappedArrayLevel", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaGetSymbolAddress", {"hipGetSymbolAddress", CONV_MEMORY, API_RUNTIME}},
{"cudaGetSymbolSize", {"hipGetSymbolSize", CONV_MEMORY, API_RUNTIME}},
{"cudaMemPrefetchAsync", {"hipMemPrefetchAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}}, // // API_Driver ANALOGUE (cuMemPrefetchAsync)
// TODO: double check cuMemPrefetchAsync
{"cudaMemPrefetchAsync", {"hipMemPrefetchAsync", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// malloc
{"cudaMalloc", {"hipMalloc", CONV_MEMORY, API_RUNTIME}},
@@ -57,15 +81,22 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"cudaMalloc3D", {"hipMalloc3D", CONV_MEMORY, API_RUNTIME}},
{"cudaMalloc3DArray", {"hipMalloc3DArray", CONV_MEMORY, API_RUNTIME}},
{"cudaMallocManaged", {"hipMallocManaged", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
// no analogue
// NOTE: Not equal to cuMipmappedArrayCreate due to different signatures
{"cudaMallocMipmappedArray", {"hipMallocMipmappedArray", CONV_MEMORY, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaMallocPitch", {"hipMallocPitch", CONV_MEMORY, API_RUNTIME}},
// cuMemFree
{"cudaFree", {"hipFree", CONV_MEMORY, API_RUNTIME}},
// cuMemFreeHost
{"cudaFreeHost", {"hipHostFree", CONV_MEMORY, API_RUNTIME}},
{"cudaFreeArray", {"hipFreeArray", CONV_MEMORY, API_RUNTIME}},
// cuMemHostRegister
{"cudaHostRegister", {"hipHostRegister", CONV_MEMORY, API_RUNTIME}},
// cuMemHostUnregister
{"cudaHostUnregister", {"hipHostUnregister", CONV_MEMORY, API_RUNTIME}},
// hipHostAlloc deprecated - use hipHostMalloc instead
// cuMemHostAlloc
// NOTE: hipHostAlloc deprecated - use hipHostMalloc instead
{"cudaHostAlloc", {"hipHostMalloc", CONV_MEMORY, API_RUNTIME}},
// make memory functions
@@ -74,35 +105,81 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"make_cudaPos", {"make_hipPos", CONV_MEMORY, API_RUNTIME}},
// Host Register Flags
// cuMemHostGetFlags
{"cudaHostGetFlags", {"hipHostGetFlags", CONV_MEMORY, API_RUNTIME}},
// Events
{"cudaEventCreate", {"hipEventCreate", CONV_EVENT, API_RUNTIME}},
{"cudaEventCreateWithFlags", {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}},
{"cudaEventDestroy", {"hipEventDestroy", CONV_EVENT, API_RUNTIME}},
{"cudaEventRecord", {"hipEventRecord", CONV_EVENT, API_RUNTIME}},
{"cudaEventElapsedTime", {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}},
{"cudaEventSynchronize", {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}},
{"cudaEventQuery", {"hipEventQuery", CONV_EVENT, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuEventCreate due to different signatures
{"cudaEventCreate", {"hipEventCreate", CONV_EVENT, API_RUNTIME}},
// cuEventCreate
{"cudaEventCreateWithFlags", {"hipEventCreateWithFlags", CONV_EVENT, API_RUNTIME}},
// cuEventDestroy
{"cudaEventDestroy", {"hipEventDestroy", CONV_EVENT, API_RUNTIME}},
// cuEventRecord
{"cudaEventRecord", {"hipEventRecord", CONV_EVENT, API_RUNTIME}},
// cuEventElapsedTime
{"cudaEventElapsedTime", {"hipEventElapsedTime", CONV_EVENT, API_RUNTIME}},
// cuEventSynchronize
{"cudaEventSynchronize", {"hipEventSynchronize", CONV_EVENT, API_RUNTIME}},
// cuEventQuery
{"cudaEventQuery", {"hipEventQuery", CONV_EVENT, API_RUNTIME}},
// 5.6. External Resource Interoperability
// cuDestroyExternalMemory
{"cudaDestroyExternalMemory", {"hipDestroyExternalMemory", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuDestroyExternalSemaphore
{"cudaDestroyExternalSemaphore", {"hipDestroyExternalSemaphore", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuExternalMemoryGetMappedBuffer
{"cudaExternalMemoryGetMappedBuffer", {"hipExternalMemoryGetMappedBuffer", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuExternalMemoryGetMappedMipmappedArray
{"cudaExternalMemoryGetMappedMipmappedArray", {"hipExternalMemoryGetMappedMipmappedArray", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuImportExternalMemory
{"cudaImportExternalMemory", {"hipImportExternalMemory", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuImportExternalSemaphore
{"cudaImportExternalSemaphore", {"hipImportExternalSemaphore", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuSignalExternalSemaphoresAsync
{"cudaSignalExternalSemaphoresAsync", {"hipSignalExternalSemaphoresAsync", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// cuWaitExternalSemaphoresAsync
{"cudaWaitExternalSemaphoresAsync", {"hipWaitExternalSemaphoresAsync", CONV_EXT_RES, API_RUNTIME, HIP_UNSUPPORTED}},
// Streams
// no analogue
// NOTE: Not equal to cuStreamCreate due to different signatures
{"cudaStreamCreate", {"hipStreamCreate", CONV_STREAM, API_RUNTIME}},
// cuStreamCreate
{"cudaStreamCreateWithFlags", {"hipStreamCreateWithFlags", CONV_STREAM, API_RUNTIME}},
{"cudaStreamCreateWithPriority", {"hipStreamCreateWithPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamCreateWithPriority
{"cudaStreamCreateWithPriority", {"hipStreamCreateWithPriority", CONV_STREAM, API_RUNTIME}},
// cuStreamDestroy
{"cudaStreamDestroy", {"hipStreamDestroy", CONV_STREAM, API_RUNTIME}},
// cuStreamWaitEvent
{"cudaStreamWaitEvent", {"hipStreamWaitEvent", CONV_STREAM, API_RUNTIME}},
// cuStreamSynchronize
{"cudaStreamSynchronize", {"hipStreamSynchronize", CONV_STREAM, API_RUNTIME}},
// cuStreamGetFlags
{"cudaStreamGetFlags", {"hipStreamGetFlags", CONV_STREAM, API_RUNTIME}},
// cuStreamQuery
{"cudaStreamQuery", {"hipStreamQuery", CONV_STREAM, API_RUNTIME}},
// cuStreamAddCallback
{"cudaStreamAddCallback", {"hipStreamAddCallback", CONV_STREAM, API_RUNTIME}},
// cuStreamAttachMemAsync
{"cudaStreamAttachMemAsync", {"hipStreamAttachMemAsync", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
{"cudaStreamGetPriority", {"hipStreamGetPriority", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamBeginCapture
{"cudaStreamBeginCapture", {"hipStreamBeginCapture", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamEndCapture
{"cudaStreamEndCapture", {"hipStreamEndCapture", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamIsCapturing
{"cudaStreamIsCapturing", {"hipStreamIsCapturing", CONV_STREAM, API_RUNTIME, HIP_UNSUPPORTED}},
// cuStreamGetPriority
{"cudaStreamGetPriority", {"hipStreamGetPriority", CONV_STREAM, API_RUNTIME}},
// Other synchronization
{"cudaDeviceSynchronize", {"hipDeviceSynchronize", CONV_DEVICE, API_RUNTIME}},
{"cudaDeviceReset", {"hipDeviceReset", CONV_DEVICE, API_RUNTIME}},
{"cudaSetDevice", {"hipSetDevice", CONV_DEVICE, API_RUNTIME}},
{"cudaGetDevice", {"hipGetDevice", CONV_DEVICE, API_RUNTIME}},
// cuDeviceGetCount
{"cudaGetDeviceCount", {"hipGetDeviceCount", CONV_DEVICE, API_RUNTIME}},
{"cudaChooseDevice", {"hipChooseDevice", CONV_DEVICE, API_RUNTIME}},
@@ -118,20 +195,25 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
{"cudaDeviceGetAttribute", {"hipDeviceGetAttribute", CONV_DEVICE, API_RUNTIME}},
// Pointer Attributes
// struct cudaPointerAttributes
{"cudaPointerGetAttributes", {"hipPointerGetAttributes", CONV_MEMORY, API_RUNTIME}},
// no analogue
// NOTE: Not equal to cuPointerGetAttributes due to different signatures
{"cudaPointerGetAttributes", {"hipPointerGetAttributes", CONV_ADDRESSING, API_RUNTIME}},
// cuMemHostGetDevicePointer
{"cudaHostGetDevicePointer", {"hipHostGetDevicePointer", CONV_MEMORY, API_RUNTIME}},
// Device
{"cudaGetDeviceProperties", {"hipGetDeviceProperties", CONV_DEVICE, API_RUNTIME}},
// cuDeviceGetPCIBusId
{"cudaDeviceGetPCIBusId", {"hipDeviceGetPCIBusId", CONV_DEVICE, API_RUNTIME}},
// cuDeviceGetByPCIBusId
{"cudaDeviceGetByPCIBusId", {"hipDeviceGetByPCIBusId", CONV_DEVICE, API_RUNTIME}},
{"cudaDeviceGetStreamPriorityRange", {"hipDeviceGetStreamPriorityRange", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}},
// cuCtxGetStreamPriorityRange
{"cudaDeviceGetStreamPriorityRange", {"hipDeviceGetStreamPriorityRange", CONV_DEVICE, API_RUNTIME}},
{"cudaSetValidDevices", {"hipSetValidDevices", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}},
// Device Flags
{"cudaGetDeviceFlags", {"hipGetDeviceFlags", CONV_DEVICE, API_RUNTIME, HIP_UNSUPPORTED}},
// cuCtxGetFlags
{"cudaGetDeviceFlags", {"hipCtxGetFlags", CONV_DEVICE, API_RUNTIME}},
{"cudaSetDeviceFlags", {"hipSetDeviceFlags", CONV_DEVICE, API_RUNTIME}},
// Cache config
@@ -179,7 +261,7 @@ const std::map<llvm::StringRef, hipCounter> CUDA_RUNTIME_FUNCTION_MAP{
// {"cudaThreadGetSharedMemConfig", {"hipDeviceGetSharedMemConfig", CONV_DEVICE, API_RUNTIME}},
// {"cudaThreadSetSharedMemConfig", {"hipDeviceSetSharedMemConfig", CONV_DEVICE, API_RUNTIME}},
// cuCtxGetLimit
{"cudaDeviceGetLimit", {"hipDeviceGetLimit", CONV_DEVICE, API_RUNTIME}},
// Profiler
@@ -270,14 +270,14 @@ bool HipifyAction::cudaLaunchKernel(const clang::ast_matchers::MatchFinder::Matc
if (numArgs > 0) {
OS << ", ";
// Start of the first argument.
clang::SourceLocation argStart = launchKernel->getArg(0)->getLocStart();
clang::SourceLocation argStart = llcompat::getBeginLoc(launchKernel->getArg(0));
// End of the last argument.
clang::SourceLocation argEnd = launchKernel->getArg(numArgs - 1)->getLocEnd();
clang::SourceLocation argEnd = llcompat::getEndLoc(launchKernel->getArg(numArgs - 1));
OS << readSourceText(*SM, {argStart, argEnd});
}
OS << ")";
clang::SourceRange replacementRange = getWriteRange(*SM, {launchKernel->getLocStart(), launchKernel->getLocEnd()});
clang::SourceRange replacementRange = getWriteRange(*SM, {llcompat::getBeginLoc(launchKernel), llcompat::getEndLoc(launchKernel)});
clang::SourceLocation launchStart = replacementRange.getBegin();
clang::SourceLocation launchEnd = replacementRange.getEnd();
size_t length = SM->getCharacterData(clang::Lexer::getLocForEndOfToken(launchEnd, 0, *SM, DefaultLangOptions)) - SM->getCharacterData(launchStart);
@@ -320,8 +320,8 @@ bool HipifyAction::cudaSharedIncompleteArrayVar(const clang::ast_matchers::Match
}
if (!typeName.empty()) {
clang::SourceLocation slStart = sharedVar->getLocStart();
clang::SourceLocation slEnd = sharedVar->getLocEnd();
clang::SourceLocation slStart = llcompat::getBeginLoc(sharedVar->getTypeSourceInfo()->getTypeLoc());
clang::SourceLocation slEnd = llcompat::getEndLoc(sharedVar->getTypeSourceInfo()->getTypeLoc());
clang::SourceManager* SM = Result.SourceManager;
size_t repLength = SM->getCharacterData(slEnd) - SM->getCharacterData(slStart) + 1;
std::string varName = sharedVar->getNameAsString();
@@ -9,6 +9,7 @@
#include "Statistics.h"
namespace ct = clang::tooling;
using namespace llvm;
/**
* A FrontendAction that hipifies CUDA programs.
+34 -2
View File
@@ -8,11 +8,11 @@ void PrintStackTraceOnErrorSignal() {
#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 8)
llvm::sys::PrintStackTraceOnErrorSignal();
#else
llvm::sys::PrintStackTraceOnErrorSignal(clang::StringRef());
llvm::sys::PrintStackTraceOnErrorSignal(StringRef());
#endif
}
ct::Replacements& getReplacements(ct::RefactoringTool& Tool, clang::StringRef file) {
ct::Replacements& getReplacements(ct::RefactoringTool& Tool, StringRef file) {
#if LLVM_VERSION_MAJOR > 3
// getReplacements() now returns a map from filename to Replacements - so create an entry
// for this source file and return a reference to it.
@@ -40,4 +40,36 @@ void EnterPreprocessorTokenStream(clang::Preprocessor& _pp, const clang::Token *
#endif
}
clang::SourceLocation getBeginLoc(const clang::Stmt* stmt) {
#if LLVM_VERSION_MAJOR < 8
return stmt->getLocStart();
#else
return stmt->getBeginLoc();
#endif
}
clang::SourceLocation getBeginLoc(const clang::TypeLoc& typeLoc) {
#if LLVM_VERSION_MAJOR < 8
return typeLoc.getLocStart();
#else
return typeLoc.getBeginLoc();
#endif
}
clang::SourceLocation getEndLoc(const clang::Stmt* stmt) {
#if LLVM_VERSION_MAJOR < 8
return stmt->getLocEnd();
#else
return stmt->getEndLoc();
#endif
}
clang::SourceLocation getEndLoc(const clang::TypeLoc& typeLoc) {
#if LLVM_VERSION_MAJOR < 8
return typeLoc.getLocEnd();
#else
return typeLoc.getEndLoc();
#endif
}
} // namespace llcompat
+9 -1
View File
@@ -25,15 +25,23 @@ namespace llcompat {
#define LLVM_DEBUG(X) DEBUG(X)
#endif
clang::SourceLocation getBeginLoc(const clang::Stmt* stmt);
clang::SourceLocation getBeginLoc(const clang::TypeLoc& typeLoc);
clang::SourceLocation getEndLoc(const clang::Stmt* stmt);
clang::SourceLocation getEndLoc(const clang::TypeLoc& typeLoc);
void PrintStackTraceOnErrorSignal();
using namespace llvm;
/**
* Get the replacement map for a given filename in a RefactoringTool.
*
* Older LLVM versions don't actually support multiple filenames, so everything all gets
* smushed together. It is the caller's responsibility to cope with this.
*/
ct::Replacements& getReplacements(ct::RefactoringTool& Tool, clang::StringRef file);
ct::Replacements& getReplacements(ct::RefactoringTool& Tool, StringRef file);
/**
* Add a Replacement to a Replacements.