Merge 'master' into 'amd-master'
Change-Id: I11589b3fff3bb58717f4f6d7045245815bbdf0cc
This commit is contained in:
@@ -135,7 +135,7 @@
|
||||
| `cudaMemcpy` | `hipMemcpy` |
|
||||
| `cudaMemcpy2D` | `hipMemcpy2D` |
|
||||
| `cudaMemcpy2DArrayToArray` | |
|
||||
| `cudaMemcpy2DAsync` | |
|
||||
| `cudaMemcpy2DAsync` | `hipMemcpy2DAsync` |
|
||||
| `cudaMemcpy2DFromArray` | |
|
||||
| `cudaMemcpy2DFromArrayAsync` | |
|
||||
| `cudaMemcpy2DToArray` | `hipMemcpy2DToArray` |
|
||||
@@ -743,17 +743,17 @@
|
||||
| typedef | `cudaStream_t` | `hipStream_t` |
|
||||
| typedef | `cudaStreamCallback_t` | `hipStreamCallback_t` |
|
||||
| typedef | `cudaSurfaceObject_t` | |
|
||||
| typedef | `cudaTextureObject_t` | |
|
||||
| typedef | `cudaTextureObject_t` | `hipTextureObject_t` |
|
||||
| typedef | `CUuuid_stcudaUUID_t` | |
|
||||
| define | `CUDA_IPC_HANDLE_SIZE` | |
|
||||
| define | `cudaArrayCubemap` | |
|
||||
| define | `cudaArrayDefault` | |
|
||||
| define | `cudaArrayLayered` | |
|
||||
| define | `cudaArraySurfaceLoadStore` | |
|
||||
| define | `cudaArrayTextureGather` | |
|
||||
| define | `cudaArrayCubemap` | `hipArrayCubemap` |
|
||||
| define | `cudaArrayDefault` | `hipArrayDefault` |
|
||||
| define | `cudaArrayLayered` | `hipArrayLayered` |
|
||||
| define | `cudaArraySurfaceLoadStore` | `hipArraySurfaceLoadStore` |
|
||||
| define | `cudaArrayTextureGather` | `hipArrayTextureGather` |
|
||||
| define | `cudaDeviceBlockingSync` | `hipDeviceScheduleBlockingSync` |
|
||||
| define | `cudaDeviceLmemResizeToMax` | |
|
||||
| define | `cudaDeviceMapHost` | |
|
||||
| define | `cudaDeviceMapHost` | `hipDeviceMapHost` |
|
||||
| define | `cudaDeviceMask` | |
|
||||
| define | `cudaDevicePropDontCare` | |
|
||||
| define | `cudaDeviceScheduleAuto` | `hipDeviceScheduleAuto` |
|
||||
@@ -783,3 +783,10 @@
|
||||
| define | `cudaStreamLegacy` | |
|
||||
| define | `cudaStreamNonBlocking` | `hipStreamNonBlocking` |
|
||||
| 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)
|
||||
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_package(LLVM 3.8 QUIET PATHS ${HIPIFY_CLANG_LLVM_DIR} NO_DEFAULT_PATH)
|
||||
if (NOT ${LLVM_FOUND})
|
||||
find_package(LLVM 3.9 QUIET PATHS ${HIPIFY_CLANG_LLVM_DIR} NO_DEFAULT_PATH)
|
||||
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()
|
||||
if (${LLVM_FOUND})
|
||||
@@ -21,12 +23,11 @@ if (${LLVM_FOUND})
|
||||
link_directories(${LLVM_LIBRARY_DIRS})
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
add_llvm_executable(hipify-clang src/Cuda2Hip.cpp)
|
||||
find_program(LIT_COMMAND lit)
|
||||
|
||||
set(CMAKE_CXX_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
|
||||
clangASTMatchers
|
||||
clangFrontend
|
||||
@@ -51,22 +52,35 @@ if (${LLVM_FOUND})
|
||||
LLVMOption
|
||||
LLVMCore)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(hipify-clang version)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_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")
|
||||
endif()
|
||||
|
||||
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)
|
||||
|
||||
if (HIPIFY_CLANG_TESTS)
|
||||
# tests
|
||||
set(Python_ADDITIONAL_VERSIONS 2.7)
|
||||
include(FindPythonInterp)
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
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.")
|
||||
endif()
|
||||
|
||||
find_program(LIT_COMMAND lit)
|
||||
|
||||
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
configure_file(
|
||||
@@ -83,8 +97,10 @@ if (${LLVM_FOUND})
|
||||
add_custom_target(test-hipify-clang)
|
||||
add_dependencies(test-hipify-clang test-hipify)
|
||||
set_target_properties(test-hipify-clang PROPERTIES FOLDER "Tests")
|
||||
endif()
|
||||
|
||||
if (PARENT_SCOPE)
|
||||
set(BUILD_HIPIFY_CLANG 1 PARENT_SCOPE)
|
||||
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_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 structs
|
||||
cuda2hipRename["cudaMemcpy3DParms"] = {"hipMemcpy3DParms", CONV_MEM, API_RUNTIME};
|
||||
@@ -1903,6 +1909,14 @@ struct cuda2hipMap {
|
||||
cuda2hipRename["cudaAddressModeMirror"] = {"hipAddressModeMirror", 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
|
||||
cuda2hipRename["cudaCreateTextureObject"] = {"hipCreateTextureObject", CONV_TEX, API_RUNTIME};
|
||||
cuda2hipRename["cudaDestroyTextureObject"] = {"hipDestroyTextureObject", CONV_TEX, API_RUNTIME};
|
||||
@@ -3300,7 +3314,17 @@ private:
|
||||
for (unsigned argno = 0; argno < launchKernel->getNumArgs(); argno++) {
|
||||
const Expr *arg = launchKernel->getArg(argno);
|
||||
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());
|
||||
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);
|
||||
std::string outs(SM->getCharacterData(sl), SM->getCharacterData(stop) - SM->getCharacterData(sl));
|
||||
DEBUG(dbgs() << outs << "\n");
|
||||
|
||||
Reference in New Issue
Block a user