Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
ca6a441
Add hip support for caffe2 core
Apr 26, 2018
cb41397
Add MIOPEN header/wrapper to caffe2 core
Apr 26, 2018
18858cb
Add HIP device into caffe2 PB
Apr 26, 2018
51a49c1
top level makefile change for rocm/hip
May 1, 2018
3a48b1e
makefile scaffolding for AMD/RocM/HIP
May 1, 2018
b45a633
Makefile scafodding for AMD/RocM/HIP; add makefile/utility for HIP files
May 1, 2018
cda1da6
caffe2 PB update for AMD/ROCM HIP device
May 2, 2018
8f9c63a
Add AMD/RocM/Thrust dependency
May 4, 2018
a1171f0
Merge branch 'caffe2_core_hip' of github.com:petrex/pytorch into caff…
May 4, 2018
d867613
HIP threadpool update
May 4, 2018
666173d
Fix makefile macro
May 4, 2018
4609bc6
makefile fix: duplicate test/binary name
May 4, 2018
e9bdd6a
makefile clean-up
May 9, 2018
f5496be
makefile clean-up
May 9, 2018
7653aff
add HIP operator registry
May 9, 2018
8c7da75
add utilities for hip device
May 9, 2018
3db165a
Add USE_HIP to config summary
May 10, 2018
6525317
makefile fix for BUILD_TEST
May 15, 2018
7606aa1
merge latest and fix test build
May 15, 2018
0c0aa1b
merge latest
May 15, 2018
e19f33d
Fix indentation
May 15, 2018
de710b4
code clean-up
May 15, 2018
8bfa47f
Merge branch 'master' into caffe2_core_hip
bddppq May 15, 2018
00ebc31
Merge branch 'master' into caffe2_core_hip
bddppq May 15, 2018
5b01dc0
Merge branch 'master' into caffe2_core_hip
bddppq May 16, 2018
39e7253
Merge branch 'master' into caffe2_core_hip
bddppq May 16, 2018
fdf36d5
Guard builds without HIP and use the same cmake script as PyTorch to …
bddppq May 16, 2018
613ddf8
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 16, 2018
df8ab43
Setup rocm environment variables in build.sh (ideally should be done …
bddppq May 16, 2018
540306e
setup locale
bddppq May 16, 2018
8ec58db
set HIP_PLATFORM
bddppq May 16, 2018
1697b92
Revert "set HIP_PLATFORM"
bddppq May 16, 2018
ac613b0
continue the build script environment variables mess
bddppq May 16, 2018
94e9569
HCC_AMDGPU_TARGET
bddppq May 16, 2018
213689e
Cleanup the mess, has been fixed in the lastest docker images
bddppq May 16, 2018
098313f
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 16, 2018
edb048a
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 16, 2018
09cf458
Assign protobuf field hip_gpu_id a new field number for backward comp…
bddppq May 16, 2018
5368a9c
change name to avoid conflict
bddppq May 17, 2018
f0b0184
Merge branch 'master' into caffe2_core_hip
bddppq May 17, 2018
199831d
Merge remote-tracking branch 'upstream/master' into caffe2_core_hip
May 17, 2018
69ffbed
Merge branch 'master' into caffe2_core_hip
bddppq May 18, 2018
de3437b
Merge branch 'master' into caffe2_core_hip
bddppq May 18, 2018
8469d2a
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 18, 2018
90afe3e
Fix duplicated thread pool flag
bddppq May 18, 2018
69ddbc8
Refactor cmake files to not add hip includes and libs globally
bddppq May 18, 2018
20f5870
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 18, 2018
e7a068f
Merge branch 'caffe2_core_hip' of github.com:petrex/pytorch into caff…
May 18, 2018
61846e7
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 18, 2018
868e39e
Merge branch 'master' into caffe2_core_hip
bddppq May 18, 2018
f77b1ca
Merge branch 'master' into caffe2_core_hip
bddppq May 19, 2018
bf7446a
Fix the wrong usage of environment variables detection in cmake
bddppq May 19, 2018
8fbb954
Merge branch 'master' into caffe2_core_hip
bddppq May 21, 2018
145a7c6
Merge branch 'caffe2_core_hip' of github.com:petrex/pytorch into caff…
May 21, 2018
758e5b2
Merge branch 'master' into caffe2_core_hip
bddppq May 22, 2018
50eadcf
Merge branch 'master' into caffe2_core_hip
bddppq May 22, 2018
e88cf91
Merge branch 'master' into caffe2_core_hip
bddppq May 23, 2018
f76bd00
Merge branch 'master' into caffe2_core_hip
bddppq May 23, 2018
e7a80cd
Merge branch 'caffe2_core_hip' of github.com:petrex/pytorch into caff…
May 23, 2018
6e89ad4
Add MIOPEN CNN operators
May 23, 2018
3eb604e
Revert "Add MIOPEN CNN operators"
May 23, 2018
6786b20
Merge branch 'master' into caffe2_core_hip
bddppq May 30, 2018
d5d8a69
Resolve merge conflicts
bddppq May 30, 2018
c690b1f
.
bddppq May 30, 2018
47a14c3
Merge branch 'master' into caffe2_core_hip
bddppq May 31, 2018
8becd40
Update GetAsyncNetHIPThreadPool
bddppq May 31, 2018
ee01f09
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq May 31, 2018
e51afb1
Merge branch 'master' into caffe2_core_hip
bddppq Jun 1, 2018
e7d0234
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq Jun 1, 2018
4fab330
Enable BUILD_CAFFE2 in pytorch build
bddppq Jun 2, 2018
18cfc2b
Merge branch 'master' into caffe2_core_hip
bddppq Jun 4, 2018
ad7b5a8
Unifiy USE_HIP and USE_ROCM
bddppq Jun 4, 2018
a4f29be
always check USE_ROCM
bddppq Jun 4, 2018
175f3d2
.
bddppq Jun 4, 2018
ca54b37
Merge remote-tracking branch 'origin/master' into caffe2_core_hip
bddppq Jun 4, 2018
ca0244d
remove unrelated change
bddppq Jun 4, 2018
9526670
move all core hip files to separate subdirectory
bddppq Jun 4, 2018
e4538d5
.
bddppq Jun 4, 2018
dd5f73f
.
bddppq Jun 4, 2018
f71d33c
recurse glob core directory
bddppq Jun 4, 2018
c1f46ee
.
bddppq Jun 4, 2018
8f0000b
correct include
bddppq Jun 4, 2018
325ca0e
.
bddppq Jun 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jenkins/caffe2/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ case "${BUILD_ENVIRONMENT}" in
# Ensure the ccache symlink can still find the real nvcc binary.
export PATH="/usr/local/cuda/bin:$PATH"
;;
*-rocm*)
export LANG=C.UTF-8
export LC_ALL=C.UTF-8
export HCC_AMDGPU_TARGET=gfx900
esac

# Try to include Redis support for Linux builds
Expand Down
4 changes: 4 additions & 0 deletions aten/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ add_subdirectory(src/THS)
# Find the HIP package, set the HIP paths, load the HIP CMake.
IF(USE_ROCM)
include(LoadHIP)
if (NOT PYTORCH_FOUND_HIP)
MESSAGE(FATAL_ERROR
"Could not find HIP installation")
endif()
ENDIF()

IF(MSVC)
Expand Down
56 changes: 52 additions & 4 deletions caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ endif()
if (CAFFE2_WHITELISTED_FILES)
caffe2_do_whitelist(Caffe2_CPU_SRCS CAFFE2_WHITELISTED_FILES)
caffe2_do_whitelist(Caffe2_GPU_SRCS CAFFE2_WHITELISTED_FILES)
caffe2_do_whitelist(Caffe2_HIP_SRCS CAFFE2_WHITELISTED_FILES)
endif()

# Debug messages - if you want to get a list of source files, enable the
Expand Down Expand Up @@ -119,6 +120,16 @@ if (FALSE)
message(STATUS " " ${tmp})
endforeach()

message(STATUS "HIP sources: ")
foreach(tmp ${Caffe2_HIP_SRCS})
message(STATUS " " ${tmp})
endforeach()

message(STATUS "HIP test sources: ")
foreach(tmp ${Caffe2_HIP_TEST_SRCS})
message(STATUS " " ${tmp})
endforeach()

message(STATUS "ATen CPU test sources: ")
foreach(tmp ${ATen_CPU_TEST_SRCS})
message(STATUS " " ${tmp})
Expand Down Expand Up @@ -194,7 +205,7 @@ caffe2_interface_library(caffe2 caffe2_library)
list(APPEND Caffe2_MAIN_LIBS caffe2_library)

# ---[ CUDA library.
if(USE_CUDA OR USE_ROCM)
if(USE_CUDA OR (USE_ROCM AND NOT BUILD_CAFFE2))
# A hack to deal with cuda library dependencies and modern CMake: the
# CUDA_ADD_LIBRARY includes a target_link_libraries, and as a result,
# one cannot use PUBLIC/PRIVATE/INTERFACE for the target anymore. This
Expand Down Expand Up @@ -232,6 +243,28 @@ if(USE_CUDA OR USE_ROCM)
list(APPEND Caffe2_MAIN_LIBS caffe2_gpu_library)
endif()

# ---[ Caffe2 HIP sources.
if(BUILD_CAFFE2)
if(USE_ROCM)
HIP_ADD_LIBRARY(caffe2_hip ${Caffe2_HIP_SRCS})
set_target_properties(caffe2_hip PROPERTIES COMPILE_FLAGS ${Caffe2_HIP_CXX_FLAGS})

target_include_directories(
caffe2_hip PUBLIC ${Caffe2_HIP_INCLUDES})
target_include_directories(
caffe2_hip INTERFACE $<INSTALL_INTERFACE:include>)

target_link_libraries(caffe2_hip PUBLIC caffe2)
target_link_libraries(caffe2_hip PUBLIC ${Caffe2_HIP_DEPENDENCY_LIBS})

set_target_properties(caffe2_hip PROPERTIES LINKER_LANGUAGE HIP)

caffe2_interface_library(caffe2_hip caffe2_hip_library)
list(APPEND Caffe2_MAIN_LIBS caffe2_hip_library)
install(TARGETS caffe2_hip EXPORT Caffe2Targets DESTINATION lib)
endif()
endif()

# ---[ Check if warnings should be errors.
if ($ENV{WERROR})
target_compile_options(caffe2 PRIVATE -Werror)
Expand All @@ -244,9 +277,12 @@ endif()
if(BUILD_CAFFE2)
if (BUILD_TEST)
set(Caffe2_ALL_TEST_SRCS ${Caffe2_CPU_TEST_SRCS})
if (USE_CUDA OR USE_ROCM)
if (USE_CUDA)
list(APPEND Caffe2_ALL_TEST_SRCS ${Caffe2_GPU_TEST_SRCS})
endif()
if(USE_ROCM)
list(APPEND Caffe2_ALL_TEST_SRCS ${Caffe2_HIP_TEST_SRCS})
endif()

foreach(test_src ${Caffe2_ALL_TEST_SRCS})
get_filename_component(test_name ${test_src} NAME_WE)
Expand All @@ -258,6 +294,18 @@ if(BUILD_CAFFE2)
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
install(TARGETS ${test_name} DESTINATION test)
endforeach()

if(USE_ROCM)
foreach(test_src ${Caffe2_HIP_TEST_SRCS})
get_filename_component(test_name ${test_src} NAME_WE)
set_target_properties(${test_name} PROPERTIES COMPILE_FLAGS ${Caffe2_HIP_CXX_FLAGS})
set_target_properties(${test_name} PROPERTIES LINKER_LANGUAGE HIP)
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.0)
target_compile_features(${test_name} PRIVATE cxx_range_for)
endif()
endforeach()
endif()

endif()
endif()

Expand Down Expand Up @@ -336,7 +384,7 @@ if(BUILD_CAFFE2)
endif(WIN32)
install(TARGETS caffe2_pybind11_state DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python")

if(USE_CUDA OR USE_ROCM)
if(USE_CUDA)
add_library(caffe2_pybind11_state_gpu MODULE ${Caffe2_GPU_PYTHON_SRCS})
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES PREFIX "" DEBUG_POSTFIX "")
Expand Down Expand Up @@ -366,7 +414,7 @@ if(BUILD_CAFFE2)
COMMAND ${CMAKE_COMMAND} -E copy
$<TARGET_FILE:caffe2_pybind11_state>
${CMAKE_BINARY_DIR}/caffe2/python)
if (USE_CUDA OR USE_ROCM)
if (USE_CUDA)
add_dependencies(windows_python_copy_lib caffe2_pybind11_state_gpu)
add_custom_command(
TARGET windows_python_copy_lib POST_BUILD
Expand Down
18 changes: 18 additions & 0 deletions caffe2/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,43 @@ set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
file(GLOB tmp *_test.cc)
exclude(Caffe2_GPU_SRCS "${Caffe2_GPU_SRCS}" ${tmp})

# ---[ HIP files
file(GLOB_RECURSE tmp *_hip.cc)
set(Caffe2_HIP_SRCS ${Caffe2_HIP_SRCS} ${tmp})
# ------[ MIOpen files
file(GLOB_RECURSE tmp *_miopen.cc)
set(Caffe2_HIP_SRCS ${Caffe2_HIP_SRCS} ${tmp})
# exclude test files
file(GLOB_RECURSE tmp *_test.cc)
exclude(Caffe2_HIP_SRCS "${Caffe2_HIP_SRCS}" ${tmp})

# ---[ CPU files.
file(GLOB tmp *.cc)
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${tmp})
# exclude test files and gpu files
file(GLOB tmp *_test.cc)
exclude(Caffe2_CPU_SRCS "${Caffe2_CPU_SRCS}" ${tmp})
exclude(Caffe2_CPU_SRCS "${Caffe2_CPU_SRCS}" ${Caffe2_GPU_SRCS})
exclude(Caffe2_CPU_SRCS "${Caffe2_CPU_SRCS}" ${Caffe2_HIP_SRCS})

# ---[ GPU test files
file(GLOB tmp *_gpu_test.cc)
set(Caffe2_GPU_TEST_SRCS ${Caffe2_GPU_TEST_SRCS} ${tmp})

# ---[ HIP test files
file(GLOB_RECURSE tmp *_hip_test.cc)
set(Caffe2_HIP_TEST_SRCS ${Caffe2_HIP_TEST_SRCS} ${tmp})

# ---[ CPU test files
file(GLOB tmp *_test.cc)
set(Caffe2_CPU_TEST_SRCS ${Caffe2_CPU_TEST_SRCS} ${tmp})
exclude(Caffe2_CPU_TEST_SRCS "${Caffe2_CPU_TEST_SRCS}" ${Caffe2_GPU_TEST_SRCS})
exclude(Caffe2_CPU_TEST_SRCS "${Caffe2_CPU_TEST_SRCS}" ${Caffe2_HIP_TEST_SRCS})

# ---[ Send the lists to the parent scope.
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} PARENT_SCOPE)
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} PARENT_SCOPE)
set(Caffe2_HIP_SRCS ${Caffe2_HIP_SRCS} PARENT_SCOPE)
set(Caffe2_CPU_TEST_SRCS ${Caffe2_CPU_TEST_SRCS} PARENT_SCOPE)
set(Caffe2_GPU_TEST_SRCS ${Caffe2_GPU_TEST_SRCS} PARENT_SCOPE)
set(Caffe2_HIP_TEST_SRCS ${Caffe2_HIP_TEST_SRCS} PARENT_SCOPE)
9 changes: 9 additions & 0 deletions caffe2/core/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@ namespace caffe2 {
// Do not directly use this variable, but instead use the HasCudaRuntime()
// function below.
std::atomic<bool> g_caffe2_has_cuda_linked{false};
std::atomic<bool> g_caffe2_has_hip_linked{false};

bool HasCudaRuntime() {
return g_caffe2_has_cuda_linked.load();
}

bool HasHipRuntime() {
return g_caffe2_has_hip_linked.load();
}

namespace internal {
void SetCudaRuntimeFlag() {
g_caffe2_has_cuda_linked.store(true);
}

void SetHipRuntimeFlag() {
g_caffe2_has_hip_linked.store(true);
}
} // namespace internal

const std::map<string, string>& GetBuildOptions() {
Expand Down
2 changes: 2 additions & 0 deletions caffe2/core/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,13 @@ class SkipIndices<> {
// as the underlying boolean variable is going to be switched on when one
// loads libcaffe2_gpu.so.
bool HasCudaRuntime();
bool HasHipRuntime();
namespace internal {
// Sets the Cuda Runtime flag that is used by HasCudaRuntime(). You should
// never use this function - it is only used by the Caffe2 gpu code to notify
// Caffe2 core that cuda runtime has been loaded.
void SetCudaRuntimeFlag();
void SetHipRuntimeFlag();
}
// Returns which setting Caffe2 was configured and built with (exported from
// CMake)
Expand Down
Loading