-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Demostration of cmake refine for HIP support. #9165
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
if(NOT WITH_AMD_GPU) | ||
return() | ||
endif() | ||
|
||
include_directories("/opt/rocm/include") | ||
include_directories("/opt/rocm/hipblas/include") | ||
include_directories("/opt/rocm/hiprand/include") | ||
include_directories("/opt/rocm/rocrand/include") | ||
include_directories("/opt/rocm/rccl/include") | ||
include_directories("/opt/rocm/thrust") | ||
|
||
list(APPEND EXTERNAL_LIBS "-L/opt/rocm/lib/ -lhip_hcc") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are too many hard codes in this file. Maybe we can modify the |
||
|
||
set(HIP_HCC_FLAGS "${HIP_HCC_FLAGS} -fPIC -DPADDLE_WITH_HIP -std=c++14" ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sabreshao , could you check the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sunway513 @reyoung c++14 is to enable "function return type deduction in lambda", which may be needed in following PR. |
||
|
||
if(WITH_DSO) | ||
set(HIP_HCC_FLAGS "${HIP_HCC_FLAGS} -DPADDLE_USE_DSO") | ||
endif(WITH_DSO) | ||
|
||
if(WITH_DOUBLE) | ||
set(HIP_HCC_FLAGS "${HIP_HCC_FLAGS} -DPADDLE_TYPE_DOUBLE") | ||
endif(WITH_DOUBLE) | ||
|
||
if(WITH_TESTING) | ||
set(HIP_HCC_FLAGS "${HIP_HCC_FLAGS} -DPADDLE_WITH_TESTING") | ||
endif(WITH_TESTING) | ||
|
||
if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
list(APPEND HIP_HCC_FLAGS ${CMAKE_CXX_FLAGS_DEBUG}) | ||
elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") | ||
list(APPEND HIP_HCC_FLAGS ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}) | ||
elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") | ||
list(APPEND HIP_HCC_FLAGS ${CMAKE_CXX_FLAGS_MINSIZEREL}) | ||
endif() | ||
|
||
if("x${HCC_HOME}" STREQUAL "x") | ||
set(HCC_HOME "/opt/rocm/hcc") | ||
endif() | ||
|
||
set(CMAKE_HIP_LINK_EXECUTABLE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>") | ||
set(CMAKE_HIP_CREATE_SHARED_LIBRARY "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -shared") | ||
set(CMAKE_HIP_CREATE_SHARED_MODULE "${HIP_HIPCC_CMAKE_LINKER_HELPER} ${HCC_HOME} <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -shared") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* Copyright (c) 2018 paddlepaddle Authors. All Rights Reserved. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. */ | ||
|
||
#include <hip/hip_runtime.h> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
if(WITH_PYTHON) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of updating this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason of updating pybind/CMakeLists.txt is that shared library which refers any HIP kernel must be linked with hipcc rather than gcc. |
||
cc_library(paddle_pybind SHARED | ||
SRCS pybind.cc exception.cc protobuf.cc const_value.cc recordio.cc | ||
DEPS pybind python backward proto_desc paddle_memory executor prune init profiler feed_fetch_method | ||
${GLOB_OP_LIB}) | ||
if(NOT APPLE AND NOT ANDROID) | ||
target_link_libraries(paddle_pybind rt) | ||
endif(NOT APPLE AND NOT ANDROID) | ||
if(WITH_AMD_GPU) | ||
hip_library(paddle_pybind SHARED | ||
SRCS pybind.cc exception.cc protobuf.cc const_value.cc recordio.cc | ||
DEPS pybind python backward proto_desc paddle_memory executor prune init profiler feed_fetch_method | ||
${GLOB_OP_LIB}) | ||
else() | ||
cc_library(paddle_pybind SHARED | ||
SRCS pybind.cc exception.cc protobuf.cc const_value.cc recordio.cc | ||
DEPS pybind python backward proto_desc paddle_memory executor prune init profiler feed_fetch_method | ||
${GLOB_OP_LIB}) | ||
if(NOT APPLE AND NOT ANDROID) | ||
target_link_libraries(paddle_pybind rt) | ||
endif(NOT APPLE AND NOT ANDROID) | ||
endif(WITH_AMD_GPU) | ||
endif(WITH_PYTHON) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could
/opt/rocm/include
etc be a relative path like${CUDA_INCLUDE_DIRS}
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until now no such thing is defined in HIP/ROCm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we don't have such define. NV defines
/usr/local/cuda
as the symbolic link, that's why they need those env vars so users can define those to point to the absolute CUDA paths.