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)
set(SPARSE_LINKER_LIBS "")
if(USE_CUDA)
if(USE_CUDA OR USE_HIP)
add_definitions(-DDGL_USE_CUDA)
enable_language(CUDA)
enable_language(HIP)
endif()
# For windows, define NOMINMAX to avoid conflict with std::min/max
......@@ -49,7 +49,7 @@ file(GLOB SPARSE_SRC
${SPARSE_DIR}/*.cc
${SPARSE_DIR}/cpu/*.cc
)
if(USE_CUDA)
if(USE_HIP)
file(GLOB SPARSE_CUDA_SRC
${SPARSE_DIR}/cuda/*.cu
)
......
......@@ -4,6 +4,9 @@ set -e
mkdir -p build
mkdir -p $BINDIR/dgl_sparse
echo ">>>>> SPARSE DIR: $BINDIR"
cd build
if [ $(uname) = 'Darwin' ]; then
......@@ -12,14 +15,15 @@ else
CPSOURCE=*.so
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_FLAGS="$CMAKE_FLAGS -DDGL_INCLUDE_DIRS=${INCLUDEDIR// /;} -DDGL_BUILD_DIR=$BINDIR"
echo $CMAKE_FLAGS
if [ $# -eq 0 ]; then
$CMAKE_COMMAND $CMAKE_FLAGS ..
make -j
make -j VERBOSE=1
cp -v $CPSOURCE $BINDIR/dgl_sparse
else
for PYTHON_INTERP in $@; do
......@@ -27,7 +31,7 @@ else
mkdir -p $TORCH_VER
cd $TORCH_VER
$CMAKE_COMMAND $CMAKE_FLAGS -DPYTHON_INTERP=$PYTHON_INTERP ../..
make -j
make -j VERBOSE=1
cp -v $CPSOURCE $BINDIR/dgl_sparse
cd ..
done
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file elementwise_op.cc
......@@ -11,7 +12,7 @@
#include <memory>
#include "./utils.h"
#include "utils.h"
namespace dgl {
namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file matmul.cc
* @brief DGL sparse matrix multiplication functions.
*/
#include "./matmul.h"
#include "matmul.h"
// clang-format off
#include <sparse/dgl_headers.h>
......@@ -12,7 +13,7 @@
#include <sparse/sparse_matrix.h>
#include <torch/script.h>
#include "./utils.h"
#include "utils.h"
namespace dgl {
namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2023 by Contributors
* @file matrix_ops_impl.h
......@@ -12,7 +13,7 @@
#include <tuple>
#include <vector>
#include "./utils.h"
#include "utils.h"
namespace dgl {
namespace sparse {} // namespace sparse
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file sddmm.cc
......@@ -9,8 +10,8 @@
#include <sstream>
#include "./matmul.h"
#include "./utils.h"
#include "matmul.h"
#include "utils.h"
namespace dgl {
namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file softmax.cc
......@@ -8,8 +9,8 @@
#include <sparse/sparse_matrix.h>
#include <torch/script.h>
#include "./matmul.h"
#include "./utils.h"
#include "matmul.h"
#include "utils.h"
namespace dgl {
namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file sparse_format.cc
......@@ -9,7 +10,7 @@
#include <sparse/sparse_format.h>
#include "./utils.h"
#include "utils.h"
namespace dgl {
namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file sparse_matrix.cc
......@@ -12,7 +13,7 @@
#include <sparse/sparse_matrix.h>
#include <torch/script.h>
#include "./utils.h"
#include "utils.h"
namespace dgl {
namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file sparse_matrix_coalesce.cc
......@@ -9,7 +10,7 @@
#include <sparse/sparse_matrix.h>
#include "./utils.h"
#include "utils.h"
namespace dgl {
namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file spmm.cc
......@@ -11,8 +12,8 @@
#include <sstream>
#include "./matmul.h"
#include "./utils.h"
#include "matmul.h"
#include "utils.h"
namespace dgl {
namespace sparse {
......
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2022 by Contributors
* @file spspmm.cc
......@@ -9,8 +10,8 @@
#include <sparse/spspmm.h>
#include <torch/script.h>
#include "./matmul.h"
#include "./utils.h"
#include "matmul.h"
#include "utils.h"
namespace dgl {
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