Commit f119ea7c authored by sangwzh's avatar sangwzh
Browse files

update dgl_sparse code to hip

parent 6ac701f8
...@@ -22,9 +22,9 @@ list(GET TORCH_VERSION_LIST 1 TORCH_VERSION_MINOR) ...@@ -22,9 +22,9 @@ list(GET TORCH_VERSION_LIST 1 TORCH_VERSION_MINOR)
set(SPARSE_LINKER_LIBS "") set(SPARSE_LINKER_LIBS "")
if(USE_CUDA) if(USE_CUDA OR USE_HIP)
add_definitions(-DDGL_USE_CUDA) add_definitions(-DDGL_USE_CUDA)
enable_language(CUDA) enable_language(HIP)
endif() endif()
# For windows, define NOMINMAX to avoid conflict with std::min/max # For windows, define NOMINMAX to avoid conflict with std::min/max
...@@ -49,7 +49,7 @@ file(GLOB SPARSE_SRC ...@@ -49,7 +49,7 @@ file(GLOB SPARSE_SRC
${SPARSE_DIR}/*.cc ${SPARSE_DIR}/*.cc
${SPARSE_DIR}/cpu/*.cc ${SPARSE_DIR}/cpu/*.cc
) )
if(USE_CUDA) if(USE_HIP)
file(GLOB SPARSE_CUDA_SRC file(GLOB SPARSE_CUDA_SRC
${SPARSE_DIR}/cuda/*.cu ${SPARSE_DIR}/cuda/*.cu
) )
......
...@@ -4,6 +4,9 @@ set -e ...@@ -4,6 +4,9 @@ set -e
mkdir -p build mkdir -p build
mkdir -p $BINDIR/dgl_sparse mkdir -p $BINDIR/dgl_sparse
echo ">>>>> SPARSE DIR: $BINDIR"
cd build cd build
if [ $(uname) = 'Darwin' ]; then if [ $(uname) = 'Darwin' ]; then
...@@ -12,14 +15,15 @@ else ...@@ -12,14 +15,15 @@ else
CPSOURCE=*.so CPSOURCE=*.so
fi fi
CMAKE_FLAGS="-DCUDA_TOOLKIT_ROOT_DIR=$CUDA_TOOLKIT_ROOT_DIR -DTORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST -DUSE_CUDA=$USE_CUDA -DEXTERNAL_DMLC_LIB_PATH=$EXTERNAL_DMLC_LIB_PATH" # CMAKE_FLAGS="-DCUDA_TOOLKIT_ROOT_DIR=$CUDA_TOOLKIT_ROOT_DIR -DTORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST -DUSE_CUDA=$USE_CUDA -DEXTERNAL_DMLC_LIB_PATH=$EXTERNAL_DMLC_LIB_PATH"
CMAKE_FLAGS="-DTORCH_CUDA_ARCH_LIST=$TORCH_HIP_ARCH_LIST -DUSE_HIP=$USE_HIP -DEXTERNAL_DMLC_LIB_PATH=$EXTERNAL_DMLC_LIB_PATH"
# CMake passes in the list of directories separated by spaces. Here we replace them with semicolons. # CMake passes in the list of directories separated by spaces. Here we replace them with semicolons.
CMAKE_FLAGS="$CMAKE_FLAGS -DDGL_INCLUDE_DIRS=${INCLUDEDIR// /;} -DDGL_BUILD_DIR=$BINDIR" CMAKE_FLAGS="$CMAKE_FLAGS -DDGL_INCLUDE_DIRS=${INCLUDEDIR// /;} -DDGL_BUILD_DIR=$BINDIR"
echo $CMAKE_FLAGS echo $CMAKE_FLAGS
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
$CMAKE_COMMAND $CMAKE_FLAGS .. $CMAKE_COMMAND $CMAKE_FLAGS ..
make -j make -j VERBOSE=1
cp -v $CPSOURCE $BINDIR/dgl_sparse cp -v $CPSOURCE $BINDIR/dgl_sparse
else else
for PYTHON_INTERP in $@; do for PYTHON_INTERP in $@; do
...@@ -27,7 +31,7 @@ else ...@@ -27,7 +31,7 @@ else
mkdir -p $TORCH_VER mkdir -p $TORCH_VER
cd $TORCH_VER cd $TORCH_VER
$CMAKE_COMMAND $CMAKE_FLAGS -DPYTHON_INTERP=$PYTHON_INTERP ../.. $CMAKE_COMMAND $CMAKE_FLAGS -DPYTHON_INTERP=$PYTHON_INTERP ../..
make -j make -j VERBOSE=1
cp -v $CPSOURCE $BINDIR/dgl_sparse cp -v $CPSOURCE $BINDIR/dgl_sparse
cd .. cd ..
done done
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file elementwise_op.cc * @file elementwise_op.cc
...@@ -11,7 +12,7 @@ ...@@ -11,7 +12,7 @@
#include <memory> #include <memory>
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file matmul.cc * @file matmul.cc
* @brief DGL sparse matrix multiplication functions. * @brief DGL sparse matrix multiplication functions.
*/ */
#include "./matmul.h" #include "matmul.h"
// clang-format off // clang-format off
#include <sparse/dgl_headers.h> #include <sparse/dgl_headers.h>
...@@ -12,7 +13,7 @@ ...@@ -12,7 +13,7 @@
#include <sparse/sparse_matrix.h> #include <sparse/sparse_matrix.h>
#include <torch/script.h> #include <torch/script.h>
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2023 by Contributors * Copyright (c) 2023 by Contributors
* @file matrix_ops_impl.h * @file matrix_ops_impl.h
...@@ -12,7 +13,7 @@ ...@@ -12,7 +13,7 @@
#include <tuple> #include <tuple>
#include <vector> #include <vector>
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse {} // namespace sparse namespace sparse {} // namespace sparse
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file sddmm.cc * @file sddmm.cc
...@@ -9,8 +10,8 @@ ...@@ -9,8 +10,8 @@
#include <sstream> #include <sstream>
#include "./matmul.h" #include "matmul.h"
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file softmax.cc * @file softmax.cc
...@@ -8,8 +9,8 @@ ...@@ -8,8 +9,8 @@
#include <sparse/sparse_matrix.h> #include <sparse/sparse_matrix.h>
#include <torch/script.h> #include <torch/script.h>
#include "./matmul.h" #include "matmul.h"
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file sparse_format.cc * @file sparse_format.cc
...@@ -9,7 +10,7 @@ ...@@ -9,7 +10,7 @@
#include <sparse/sparse_format.h> #include <sparse/sparse_format.h>
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file sparse_matrix.cc * @file sparse_matrix.cc
...@@ -12,7 +13,7 @@ ...@@ -12,7 +13,7 @@
#include <sparse/sparse_matrix.h> #include <sparse/sparse_matrix.h>
#include <torch/script.h> #include <torch/script.h>
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file sparse_matrix_coalesce.cc * @file sparse_matrix_coalesce.cc
...@@ -9,7 +10,7 @@ ...@@ -9,7 +10,7 @@
#include <sparse/sparse_matrix.h> #include <sparse/sparse_matrix.h>
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file spmm.cc * @file spmm.cc
...@@ -11,8 +12,8 @@ ...@@ -11,8 +12,8 @@
#include <sstream> #include <sstream>
#include "./matmul.h" #include "matmul.h"
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2022 by Contributors * Copyright (c) 2022 by Contributors
* @file spspmm.cc * @file spspmm.cc
...@@ -9,8 +10,8 @@ ...@@ -9,8 +10,8 @@
#include <sparse/spspmm.h> #include <sparse/spspmm.h>
#include <torch/script.h> #include <torch/script.h>
#include "./matmul.h" #include "matmul.h"
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
namespace sparse { namespace sparse {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment