Skip to content
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

Add AMD GPU XLA Op Implementation #3486

Merged
merged 11 commits into from May 26, 2022
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -350,6 +350,10 @@ if(HAVE_CUDA OR HAVE_SUB_PROJECT_CUDA)
add_subdirectory(horovod/common/ops/cuda)
endif()

if(HAVE_ROCM)
add_subdirectory(horovod/common/ops/rocm)
endif()

# if we need compatible c++ abi
# Duplicate gloo folder and add it as a new sub-project
if(HAVE_GLOO AND ((DEFINED Tensorflow_CXX11 AND NOT Tensorflow_CXX11) OR (DEFINED Pytorch_CXX11 AND NOT Pytorch_CXX11) OR (DEFINED Mxnet_CXX11 AND NOT Mxnet_CXX11)))
Expand Down
2 changes: 1 addition & 1 deletion horovod/common/common.h
Expand Up @@ -45,7 +45,6 @@ using gpuStream_t = cudaStream_t;
throw std::logic_error(std::string("GPU Error:") + cudaGetErrorString(cuda_result)); \
} \
} while (0)
#endif
weihanmines marked this conversation as resolved.
Show resolved Hide resolved
#elif HAVE_ROCM
#include <hip/hip_runtime_api.h>
using gpuError_t = hipError_t;
Expand All @@ -64,6 +63,7 @@ using gpuStream_t = hipStream_t;
} \
} while (0)
#endif
#endif


namespace horovod {
Expand Down
16 changes: 16 additions & 0 deletions horovod/common/ops/gpu_operations.h
Expand Up @@ -176,6 +176,22 @@ class GPUAllreduce : public AllreduceOp {
double scale_factor,
std::vector<TensorTableEntry>& entries);
#endif
#if HAVE_ROCM
void MemcpyInFusionBuffer(const std::vector<TensorTableEntry>& entries,
const void*& fused_input_data, void*& buffer_data,
size_t& buffer_len) override;

void MemcpyOutFusionBuffer(const void* buffer_data,
std::vector<TensorTableEntry>& entries) override;

void ScaleMemcpyInFusionBuffer(const std::vector<TensorTableEntry>& entries,
const void*& fused_input_data,
void*& buffer_data, size_t& buffer_len,
double scale_factor);
void ScaleMemcpyOutFusionBuffer(void* buffer_data, size_t buffer_len,
double scale_factor,
std::vector<TensorTableEntry>& entries);
#endif
weihanmines marked this conversation as resolved.
Show resolved Hide resolved

void MemcpyEntryInFusionBuffer(const std::vector<TensorTableEntry>& entries,
const TensorTableEntry& e,
Expand Down
4 changes: 4 additions & 0 deletions horovod/tensorflow/mpi_ops.cc
Expand Up @@ -27,6 +27,10 @@
#define EIGEN_USE_GPU
#endif // HAVE_CUDA || HAVE_ROCM

#if HAVE_ROCM
#define EIGEN_USE_HIP
#endif

#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/shape_inference.h"
Expand Down