Merge pull request #195 from emankov/master
[HIPIFY] CUDA RT Textures and Arrays support update
[HIPIFY] cmake changes
[HIPIFY][#199][Partial fix] Fix for cudaLaunchKernel transformation
[ROCm/hip commit: e8de9dda33]
This commit is contained in:
@@ -135,7 +135,7 @@
|
|||||||
| `cudaMemcpy` | `hipMemcpy` |
|
| `cudaMemcpy` | `hipMemcpy` |
|
||||||
| `cudaMemcpy2D` | `hipMemcpy2D` |
|
| `cudaMemcpy2D` | `hipMemcpy2D` |
|
||||||
| `cudaMemcpy2DArrayToArray` | |
|
| `cudaMemcpy2DArrayToArray` | |
|
||||||
| `cudaMemcpy2DAsync` | |
|
| `cudaMemcpy2DAsync` | `hipMemcpy2DAsync` |
|
||||||
| `cudaMemcpy2DFromArray` | |
|
| `cudaMemcpy2DFromArray` | |
|
||||||
| `cudaMemcpy2DFromArrayAsync` | |
|
| `cudaMemcpy2DFromArrayAsync` | |
|
||||||
| `cudaMemcpy2DToArray` | `hipMemcpy2DToArray` |
|
| `cudaMemcpy2DToArray` | `hipMemcpy2DToArray` |
|
||||||
@@ -743,17 +743,17 @@
|
|||||||
| typedef | `cudaStream_t` | `hipStream_t` |
|
| typedef | `cudaStream_t` | `hipStream_t` |
|
||||||
| typedef | `cudaStreamCallback_t` | `hipStreamCallback_t` |
|
| typedef | `cudaStreamCallback_t` | `hipStreamCallback_t` |
|
||||||
| typedef | `cudaSurfaceObject_t` | |
|
| typedef | `cudaSurfaceObject_t` | |
|
||||||
| typedef | `cudaTextureObject_t` | |
|
| typedef | `cudaTextureObject_t` | `hipTextureObject_t` |
|
||||||
| typedef | `CUuuid_stcudaUUID_t` | |
|
| typedef | `CUuuid_stcudaUUID_t` | |
|
||||||
| define | `CUDA_IPC_HANDLE_SIZE` | |
|
| define | `CUDA_IPC_HANDLE_SIZE` | |
|
||||||
| define | `cudaArrayCubemap` | |
|
| define | `cudaArrayCubemap` | `hipArrayCubemap` |
|
||||||
| define | `cudaArrayDefault` | |
|
| define | `cudaArrayDefault` | `hipArrayDefault` |
|
||||||
| define | `cudaArrayLayered` | |
|
| define | `cudaArrayLayered` | `hipArrayLayered` |
|
||||||
| define | `cudaArraySurfaceLoadStore` | |
|
| define | `cudaArraySurfaceLoadStore` | `hipArraySurfaceLoadStore` |
|
||||||
| define | `cudaArrayTextureGather` | |
|
| define | `cudaArrayTextureGather` | `hipArrayTextureGather` |
|
||||||
| define | `cudaDeviceBlockingSync` | `hipDeviceScheduleBlockingSync` |
|
| define | `cudaDeviceBlockingSync` | `hipDeviceScheduleBlockingSync` |
|
||||||
| define | `cudaDeviceLmemResizeToMax` | |
|
| define | `cudaDeviceLmemResizeToMax` | |
|
||||||
| define | `cudaDeviceMapHost` | |
|
| define | `cudaDeviceMapHost` | `hipDeviceMapHost` |
|
||||||
| define | `cudaDeviceMask` | |
|
| define | `cudaDeviceMask` | |
|
||||||
| define | `cudaDevicePropDontCare` | |
|
| define | `cudaDevicePropDontCare` | |
|
||||||
| define | `cudaDeviceScheduleAuto` | `hipDeviceScheduleAuto` |
|
| define | `cudaDeviceScheduleAuto` | `hipDeviceScheduleAuto` |
|
||||||
@@ -783,3 +783,10 @@
|
|||||||
| define | `cudaStreamLegacy` | |
|
| define | `cudaStreamLegacy` | |
|
||||||
| define | `cudaStreamNonBlocking` | `hipStreamNonBlocking` |
|
| define | `cudaStreamNonBlocking` | `hipStreamNonBlocking` |
|
||||||
| define | `cudaStreamPerThread` | |
|
| define | `cudaStreamPerThread` | |
|
||||||
|
| define | `cudaTextureType1D` | `hipTextureType1D` |
|
||||||
|
| define | `cudaTextureType2D` | `hipTextureType2D` |
|
||||||
|
| define | `cudaTextureType3D` | `hipTextureType3D` |
|
||||||
|
| define | `cudaTextureTypeCubemap` | `hipTextureTypeCubemap` |
|
||||||
|
| define | `cudaTextureType1DLayered` | `hipTextureType1DLayered` |
|
||||||
|
| define | `cudaTextureType2DLayered` | `hipTextureType2DLayered` |
|
||||||
|
| define | `cudaTextureTypeCubemapLayered` | `hipTextureTypeCubemapLayered` |
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
cmake_minimum_required(VERSION 2.8.8)
|
cmake_minimum_required(VERSION 2.8.8)
|
||||||
project(hipify-clang)
|
project(hipify-clang)
|
||||||
|
|
||||||
set(BUILD_HIPIFY_CLANG 0 PARENT_SCOPE)
|
if (PARENT_SCOPE)
|
||||||
|
set(BUILD_HIPIFY_CLANG 0 PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Find LLVM package
|
# Find LLVM package
|
||||||
find_package(LLVM 3.8 QUIET PATHS ${HIPIFY_CLANG_LLVM_DIR} NO_DEFAULT_PATH)
|
find_package(LLVM 3.8 QUIET PATHS ${HIPIFY_CLANG_LLVM_DIR} NO_DEFAULT_PATH)
|
||||||
if (NOT ${LLVM_FOUND})
|
if (NOT ${LLVM_FOUND})
|
||||||
find_package(LLVM 3.9 QUIET PATHS ${HIPIFY_CLANG_LLVM_DIR} NO_DEFAULT_PATH)
|
find_package(LLVM 3.9 QUIET PATHS ${HIPIFY_CLANG_LLVM_DIR} NO_DEFAULT_PATH)
|
||||||
if (NOT ${LLVM_FOUND})
|
if (NOT ${LLVM_FOUND})
|
||||||
message(STATUS "hipify-clang will not be built. To build it please specify absolute path to LLVM 3.8 or LLVM 3.9 package using -DHIPIFY_CLANG_LLVM_DIR")
|
message(STATUS "hipify-clang will not be built. To build it please specify absolute path to LLVM 3.8 or LLVM 3.9 package/dist using -DHIPIFY_CLANG_LLVM_DIR")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if (${LLVM_FOUND})
|
if (${LLVM_FOUND})
|
||||||
@@ -21,12 +23,11 @@ if (${LLVM_FOUND})
|
|||||||
link_directories(${LLVM_LIBRARY_DIRS})
|
link_directories(${LLVM_LIBRARY_DIRS})
|
||||||
add_definitions(${LLVM_DEFINITIONS})
|
add_definitions(${LLVM_DEFINITIONS})
|
||||||
add_llvm_executable(hipify-clang src/Cuda2Hip.cpp)
|
add_llvm_executable(hipify-clang src/Cuda2Hip.cpp)
|
||||||
find_program(LIT_COMMAND lit)
|
|
||||||
|
|
||||||
set(CMAKE_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang++)
|
set(CMAKE_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang++)
|
||||||
set(CMAKE_C_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang)
|
set(CMAKE_C_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang)
|
||||||
|
|
||||||
# Link against LLVM and CLANG tools libraries
|
# Link against LLVM and CLANG libraries
|
||||||
target_link_libraries(hipify-clang
|
target_link_libraries(hipify-clang
|
||||||
clangASTMatchers
|
clangASTMatchers
|
||||||
clangFrontend
|
clangFrontend
|
||||||
@@ -51,22 +52,35 @@ if (${LLVM_FOUND})
|
|||||||
LLVMOption
|
LLVMOption
|
||||||
LLVMCore)
|
LLVMCore)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
target_link_libraries(hipify-clang version)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
|
||||||
|
if(MSVC)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR- /EHs- /EHc-")
|
||||||
|
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} /SUBSYSTEM:WINDOWS")
|
||||||
|
else()
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -fno-rtti -fvisibility-inlines-hidden")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -fno-rtti -fvisibility-inlines-hidden")
|
||||||
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHIPIFY_CLANG_RES=\\\"${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}\\\"")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHIPIFY_CLANG_RES=\\\"${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}\\\"")
|
||||||
|
|
||||||
install(TARGETS hipify-clang DESTINATION bin)
|
install(TARGETS hipify-clang DESTINATION bin)
|
||||||
|
|
||||||
|
if (HIPIFY_CLANG_TESTS)
|
||||||
# tests
|
# tests
|
||||||
set(Python_ADDITIONAL_VERSIONS 2.7)
|
set(Python_ADDITIONAL_VERSIONS 2.7)
|
||||||
include(FindPythonInterp)
|
include(FindPythonInterp)
|
||||||
if(NOT PYTHONINTERP_FOUND)
|
if(NOT PYTHONINTERP_FOUND)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Unable to find Python interpreter, required for builds and testing\n\n"
|
"Unable to find Python interpreter, required for builds and testing.\n\n"
|
||||||
"Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
|
"Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_program(LIT_COMMAND lit)
|
||||||
|
|
||||||
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
configure_file(
|
configure_file(
|
||||||
@@ -83,8 +97,10 @@ if (${LLVM_FOUND})
|
|||||||
add_custom_target(test-hipify-clang)
|
add_custom_target(test-hipify-clang)
|
||||||
add_dependencies(test-hipify-clang test-hipify)
|
add_dependencies(test-hipify-clang test-hipify)
|
||||||
set_target_properties(test-hipify-clang PROPERTIES FOLDER "Tests")
|
set_target_properties(test-hipify-clang PROPERTIES FOLDER "Tests")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (PARENT_SCOPE)
|
||||||
set(BUILD_HIPIFY_CLANG 1 PARENT_SCOPE)
|
set(BUILD_HIPIFY_CLANG 1 PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# vim: ts=4:sw=4:expandtab:smartindent
|
endif()
|
||||||
|
|||||||
@@ -1379,6 +1379,12 @@ struct cuda2hipMap {
|
|||||||
cuda2hipRename["cudaMipmappedArray_t"] = {"hipMipmappedArray_t", CONV_MEM, API_RUNTIME};
|
cuda2hipRename["cudaMipmappedArray_t"] = {"hipMipmappedArray_t", CONV_MEM, API_RUNTIME};
|
||||||
cuda2hipRename["cudaMipmappedArray_const_t"] = {"hipMipmappedArray_const_t", CONV_MEM, API_RUNTIME};
|
cuda2hipRename["cudaMipmappedArray_const_t"] = {"hipMipmappedArray_const_t", CONV_MEM, API_RUNTIME};
|
||||||
|
|
||||||
|
cuda2hipRename["cudaArrayDefault"] = {"hipArrayDefault", CONV_MEM, API_RUNTIME}; // 0x00
|
||||||
|
cuda2hipRename["cudaArrayLayered"] = {"hipArrayLayered", CONV_MEM, API_RUNTIME}; // 0x01 // Unsupported yet on NVCC path
|
||||||
|
cuda2hipRename["cudaArraySurfaceLoadStore"] = {"hipArraySurfaceLoadStore", CONV_MEM, API_RUNTIME}; // 0x02 // Unsupported yet on NVCC path
|
||||||
|
cuda2hipRename["cudaArrayCubemap"] = {"hipArrayCubemap", CONV_MEM, API_RUNTIME}; // 0x04 // Unsupported yet on NVCC path
|
||||||
|
cuda2hipRename["cudaArrayTextureGather"] = {"hipArrayTextureGather", CONV_MEM, API_RUNTIME}; // 0x08 // Unsupported yet on NVCC path
|
||||||
|
|
||||||
// memcpy
|
// memcpy
|
||||||
// memcpy structs
|
// memcpy structs
|
||||||
cuda2hipRename["cudaMemcpy3DParms"] = {"hipMemcpy3DParms", CONV_MEM, API_RUNTIME};
|
cuda2hipRename["cudaMemcpy3DParms"] = {"hipMemcpy3DParms", CONV_MEM, API_RUNTIME};
|
||||||
@@ -1903,6 +1909,14 @@ struct cuda2hipMap {
|
|||||||
cuda2hipRename["cudaAddressModeMirror"] = {"hipAddressModeMirror", CONV_TEX, API_RUNTIME};
|
cuda2hipRename["cudaAddressModeMirror"] = {"hipAddressModeMirror", CONV_TEX, API_RUNTIME};
|
||||||
cuda2hipRename["cudaAddressModeBorder"] = {"hipAddressModeBorder", CONV_TEX, API_RUNTIME};
|
cuda2hipRename["cudaAddressModeBorder"] = {"hipAddressModeBorder", CONV_TEX, API_RUNTIME};
|
||||||
|
|
||||||
|
cuda2hipRename["cudaTextureType1D"] = {"hipTextureType1D", CONV_TEX, API_RUNTIME}; // 0x01 // Unsupported yet on NVCC path
|
||||||
|
cuda2hipRename["cudaTextureType2D"] = {"hipTextureType2D", CONV_TEX, API_RUNTIME}; // 0x02
|
||||||
|
cuda2hipRename["cudaTextureType3D"] = {"hipTextureType3D", CONV_TEX, API_RUNTIME}; // 0x03 // Unsupported yet on NVCC path
|
||||||
|
cuda2hipRename["cudaTextureTypeCubemap"] = {"hipTextureTypeCubemap", CONV_TEX, API_RUNTIME}; // 0x0C // Unsupported yet on NVCC path
|
||||||
|
cuda2hipRename["cudaTextureType1DLayered"] = {"hipTextureType1DLayered", CONV_TEX, API_RUNTIME}; // 0xF1 // Unsupported yet on NVCC path
|
||||||
|
cuda2hipRename["cudaTextureType2DLayered"] = {"hipTextureType2DLayered", CONV_TEX, API_RUNTIME}; // 0xF2 // Unsupported yet on NVCC path
|
||||||
|
cuda2hipRename["cudaTextureTypeCubemapLayered"] = {"hipTextureTypeCubemapLayered", CONV_TEX, API_RUNTIME}; // 0xFC // Unsupported yet on NVCC path
|
||||||
|
|
||||||
// functions
|
// functions
|
||||||
cuda2hipRename["cudaCreateTextureObject"] = {"hipCreateTextureObject", CONV_TEX, API_RUNTIME};
|
cuda2hipRename["cudaCreateTextureObject"] = {"hipCreateTextureObject", CONV_TEX, API_RUNTIME};
|
||||||
cuda2hipRename["cudaDestroyTextureObject"] = {"hipDestroyTextureObject", CONV_TEX, API_RUNTIME};
|
cuda2hipRename["cudaDestroyTextureObject"] = {"hipDestroyTextureObject", CONV_TEX, API_RUNTIME};
|
||||||
@@ -3300,7 +3314,17 @@ private:
|
|||||||
for (unsigned argno = 0; argno < launchKernel->getNumArgs(); argno++) {
|
for (unsigned argno = 0; argno < launchKernel->getNumArgs(); argno++) {
|
||||||
const Expr *arg = launchKernel->getArg(argno);
|
const Expr *arg = launchKernel->getArg(argno);
|
||||||
SourceLocation sl(arg->getLocStart());
|
SourceLocation sl(arg->getLocStart());
|
||||||
|
if (SM->isMacroBodyExpansion(sl)) {
|
||||||
|
sl = SM->getExpansionLoc(sl);
|
||||||
|
} else if (SM->isMacroArgExpansion(sl)) {
|
||||||
|
sl = SM->getImmediateSpellingLoc(sl);
|
||||||
|
}
|
||||||
SourceLocation el(arg->getLocEnd());
|
SourceLocation el(arg->getLocEnd());
|
||||||
|
if (SM->isMacroBodyExpansion(el)) {
|
||||||
|
el = SM->getExpansionLoc(el);
|
||||||
|
} else if (SM->isMacroArgExpansion(el)) {
|
||||||
|
el = SM->getImmediateSpellingLoc(el);
|
||||||
|
}
|
||||||
SourceLocation stop = Lexer::getLocForEndOfToken(el, 0, *SM, DefaultLangOptions);
|
SourceLocation stop = Lexer::getLocForEndOfToken(el, 0, *SM, DefaultLangOptions);
|
||||||
std::string outs(SM->getCharacterData(sl), SM->getCharacterData(stop) - SM->getCharacterData(sl));
|
std::string outs(SM->getCharacterData(sl), SM->getCharacterData(stop) - SM->getCharacterData(sl));
|
||||||
DEBUG(dbgs() << outs << "\n");
|
DEBUG(dbgs() << outs << "\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user