Commit 74d88bf8 authored by sangwz's avatar sangwz
Browse files

Merge branch 'dtk25.04' of http://developer.sourcefind.cn/codes/OpenDAS/dgl into 2.2.1

parents 2a1ac588 314cedc1
...@@ -105,4 +105,5 @@ def find_lib_path(name=None, search_path=None, optional=False): ...@@ -105,4 +105,5 @@ def find_lib_path(name=None, search_path=None, optional=False):
# We use the version of the incoming release for code # We use the version of the incoming release for code
# that is under development. # that is under development.
# The following line is set by dgl/python/update_version.py # The following line is set by dgl/python/update_version.py
__version__ = "2.2.1" __version__ = "2.2.1"
...@@ -123,7 +123,7 @@ class DGLContext(ctypes.Structure): ...@@ -123,7 +123,7 @@ class DGLContext(ctypes.Structure):
7: "vulkan", 7: "vulkan",
8: "metal", 8: "metal",
9: "vpi", 9: "vpi",
10: "rocm", 10: "gpu",
11: "opengl", 11: "opengl",
12: "ext_dev", 12: "ext_dev",
} }
...@@ -131,9 +131,9 @@ class DGLContext(ctypes.Structure): ...@@ -131,9 +131,9 @@ class DGLContext(ctypes.Structure):
"llvm": 1, "llvm": 1,
"stackvm": 1, "stackvm": 1,
"cpu": 1, "cpu": 1,
"gpu": 2, "gpu": 10,
"cuda": 2, "cuda": 10,
"nvptx": 2, "nvptx": 10,
"cl": 4, "cl": 4,
"opencl": 4, "opencl": 4,
"aocl": 5, "aocl": 5,
......
...@@ -116,7 +116,7 @@ def to_backend_ctx(dglctx): ...@@ -116,7 +116,7 @@ def to_backend_ctx(dglctx):
dev_type = dglctx.device_type dev_type = dglctx.device_type
if dev_type == 1: if dev_type == 1:
return th.device("cpu") return th.device("cpu")
elif dev_type == 2: elif dev_type == 2 or dev_type==10:
return th.device("cuda", dglctx.device_id) return th.device("cuda", dglctx.device_id)
else: else:
raise ValueError("Unsupported DGL device context:", dglctx) raise ValueError("Unsupported DGL device context:", dglctx)
......
...@@ -80,7 +80,8 @@ def gpu(dev_id=0): ...@@ -80,7 +80,8 @@ def gpu(dev_id=0):
ctx : DGLContext ctx : DGLContext
The created context The created context
""" """
return DGLContext(2, dev_id) # device type for dcu is 10, nv is 2
return DGLContext(10, dev_id)
def array(arr, ctx=cpu(0)): def array(arr, ctx=cpu(0)):
......
...@@ -16,7 +16,10 @@ import re ...@@ -16,7 +16,10 @@ import re
# (usually "aYYMMDD") # (usually "aYYMMDD")
# The environment variable DGL_VERSION_SUFFIX is the local version label # The environment variable DGL_VERSION_SUFFIX is the local version label
# suffix for indicating CPU and CUDA versions as in PEP 440 (e.g. "+cu102") # suffix for indicating CPU and CUDA versions as in PEP 440 (e.g. "+cu102")
__version__ = "2.2.1" + os.getenv("DGL_PRERELEASE", "") __version__ = "2.2.1" + os.getenv("DGL_PRERELEASE", "")
__version__ += os.getenv("DGL_VERSION_SUFFIX", "") __version__ += os.getenv("DGL_VERSION_SUFFIX", "")
print(__version__) print(__version__)
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file array/arith.h * @file array/arith.h
...@@ -6,13 +7,13 @@ ...@@ -6,13 +7,13 @@
#ifndef DGL_ARRAY_ARITH_H_ #ifndef DGL_ARRAY_ARITH_H_
#define DGL_ARRAY_ARITH_H_ #define DGL_ARRAY_ARITH_H_
#ifdef __CUDACC__ #ifdef __HIPCC__
#define DGLDEVICE __device__ #define DGLDEVICE __device__ __host__
#define DGLINLINE __forceinline__ #define DGLINLINE __forceinline__
#else #else
#define DGLDEVICE #define DGLDEVICE
#define DGLINLINE inline #define DGLINLINE inline
#endif // __CUDACC__ #endif // __HIPCC__
namespace dgl { namespace dgl {
namespace aten { namespace aten {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2019-2022 by Contributors * Copyright (c) 2019-2022 by Contributors
* @file array/array.cc * @file array/array.cc
...@@ -14,9 +15,9 @@ ...@@ -14,9 +15,9 @@
#include <sstream> #include <sstream>
#include "../c_api_common.h" #include "../c_api_common.h"
#include "./arith.h" #include "arith.h"
#include "./array_op.h" #include "array_op.h"
#include "./kernel_decl.h" #include "kernel_decl.h"
using namespace dgl::runtime; using namespace dgl::runtime;
...@@ -585,7 +586,7 @@ COOMatrix CSRRowWiseSampling( ...@@ -585,7 +586,7 @@ COOMatrix CSRRowWiseSampling(
// prob_or_mask is pinned and rows on GPU is valid // prob_or_mask is pinned and rows on GPU is valid
CHECK_VALID_CONTEXT(prob_or_mask, rows); CHECK_VALID_CONTEXT(prob_or_mask, rows);
ATEN_CSR_SWITCH_CUDA_UVA(mat, rows, XPU, IdType, "CSRRowWiseSampling", { ATEN_CSR_SWITCH_CUDA_UVA(mat, rows, XPU, IdType, "CSRRowWiseSampling", {
CHECK(!(prob_or_mask->dtype.bits == 8 && XPU == kDGLCUDA)) CHECK(!(prob_or_mask->dtype.bits == 8 && (XPU == kDGLCUDA || XPU == kDGLROCM)))
<< "GPU sampling with masks is currently not supported yet."; << "GPU sampling with masks is currently not supported yet.";
ATEN_FLOAT_INT8_UINT8_TYPE_SWITCH( ATEN_FLOAT_INT8_UINT8_TYPE_SWITCH(
prob_or_mask->dtype, FloatType, "probability or mask", { prob_or_mask->dtype, FloatType, "probability or mask", {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2019 by Contributors * Copyright (c) 2019 by Contributors
* @file array/array_aritch.cc * @file array/array_aritch.cc
...@@ -8,8 +9,8 @@ ...@@ -8,8 +9,8 @@
#include <dgl/runtime/ndarray.h> #include <dgl/runtime/ndarray.h>
#include "../c_api_common.h" #include "../c_api_common.h"
#include "./arith.h" #include "arith.h"
#include "./array_op.h" #include "array_op.h"
using namespace dgl::runtime; using namespace dgl::runtime;
......
...@@ -29,6 +29,7 @@ IdArray CumSum(IdArray array, bool prepend_zero) { ...@@ -29,6 +29,7 @@ IdArray CumSum(IdArray array, bool prepend_zero) {
IdType* out_d = ret.Ptr<IdType>(); IdType* out_d = ret.Ptr<IdType>();
out_d[0] = in_d[0]; out_d[0] = in_d[0];
for (int64_t i = 1; i < len; ++i) out_d[i] = out_d[i - 1] + in_d[i]; for (int64_t i = 1; i < len; ++i) out_d[i] = out_d[i - 1] + in_d[i];
std::cout << "limm cpu ret : " << ret << std::endl;
return ret; return ret;
} }
} }
......
...@@ -48,7 +48,7 @@ void swap(const PairRef<V1, V2>& r1, const PairRef<V1, V2>& r2) { ...@@ -48,7 +48,7 @@ void swap(const PairRef<V1, V2>& r1, const PairRef<V1, V2>& r2) {
} }
template <typename V1, typename V2> template <typename V1, typename V2>
struct PairIterator __host__ struct PairIterator
: public std::iterator< : public std::iterator<
std::random_access_iterator_tag, std::pair<V1, V2>, std::ptrdiff_t, std::random_access_iterator_tag, std::pair<V1, V2>, std::ptrdiff_t,
std::pair<V1*, V2*>, PairRef<V1, V2>> { std::pair<V1*, V2*>, PairRef<V1, V2>> {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2020 by Contributors * Copyright (c) 2020 by Contributors
* @file kernel/cpu/gaher_mm.cc * @file kernel/cpu/gaher_mm.cc
* @brief GatherMM C APIs and definitions. * @brief GatherMM C APIs and definitions.
*/ */
#include "./gather_mm.h" #include "gather_mm.h"
#include <dgl/array.h> #include <dgl/array.h>
......
// !!! This is a file automatically generated by hipify!!!
/*! /*!
* Copyright (c) 2022, NVIDIA Corporation * Copyright (c) 2022, NVIDIA Corporation
* Copyright (c) 2022, GT-TDAlab (Muhammed Fatih Balin & Umit V. Catalyurek) * Copyright (c) 2022, GT-TDAlab (Muhammed Fatih Balin & Umit V. Catalyurek)
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
* \file array/cuda/labor_sampling.cc * \file array/cuda/labor_sampling.cc
* \brief labor sampling * \brief labor sampling
*/ */
#include "./labor_pick.h" #include "labor_pick.h"
namespace dgl { namespace dgl {
namespace aten { namespace aten {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2020 by Contributors * Copyright (c) 2020 by Contributors
* @file array/cpu/rowwise_sampling.cc * @file array/cpu/rowwise_sampling.cc
...@@ -7,7 +8,7 @@ ...@@ -7,7 +8,7 @@
#include <numeric> #include <numeric>
#include "./rowwise_pick.h" #include "rowwise_pick.h"
namespace dgl { namespace dgl {
namespace aten { namespace aten {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2020 by Contributors * Copyright (c) 2020 by Contributors
* @file array/cpu/rowwise_topk.cc * @file array/cpu/rowwise_topk.cc
...@@ -6,7 +7,7 @@ ...@@ -6,7 +7,7 @@
#include <algorithm> #include <algorithm>
#include <numeric> #include <numeric>
#include "./rowwise_pick.h" #include "rowwise_pick.h"
namespace dgl { namespace dgl {
namespace aten { namespace aten {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2020 by Contributors * Copyright (c) 2020 by Contributors
* @file aten/cpu/sddmm.cc * @file aten/cpu/sddmm.cc
* @brief SDDMM C APIs and definitions. * @brief SDDMM C APIs and definitions.
*/ */
#include "./sddmm.h" #include "sddmm.h"
#include <dgl/array.h> #include <dgl/array.h>
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2020 by Contributors * Copyright (c) 2020 by Contributors
* @file kernel/cpu/segment_reduce.cc * @file kernel/cpu/segment_reduce.cc
* @brief Segment reduce C APIs and definitions. * @brief Segment reduce C APIs and definitions.
*/ */
#include "./segment_reduce.h" #include "segment_reduce.h"
#include <dgl/array.h> #include <dgl/array.h>
#include <string> #include <string>
#include "./spmm_binary_ops.h" #include "spmm_binary_ops.h"
namespace dgl { namespace dgl {
namespace aten { namespace aten {
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2020 by Contributors * Copyright (c) 2020 by Contributors
* @file kernel/cpu/spmm.cc * @file kernel/cpu/spmm.cc
* @brief SPMM C APIs and definitions. * @brief SPMM C APIs and definitions.
*/ */
#include "./spmm.h" #include "spmm.h"
#include <dgl/array.h> #include <dgl/array.h>
......
// !!! This is a file automatically generated by hipify!!!
/** /**
* Copyright (c) 2020 by Contributors * Copyright (c) 2020 by Contributors
* @file array/cpu/traversal.cc * @file array/cpu/traversal.cc
* @brief Graph traversal implementation * @brief Graph traversal implementation
*/ */
#include "./traversal.h" #include "traversal.h"
#include <dgl/graph_traversal.h> #include <dgl/graph_traversal.h>
......
// !!! This is a file automatically generated by hipify!!!
#include "hip/hip_runtime.h"
/** /**
* Copyright (c) 2020 by Contributors * Copyright (c) 2020 by Contributors
* @file array/cpu/array_cumsum.cu * @file array/cpu/array_cumsum.cu
* @brief Array cumsum GPU implementation * @brief Array cumsum GPU implementation
*/ */
#include <dgl/array.h> #include <dgl/array.h>
#include "../../../include/dgl/array.h"
#include <cub/cub.cuh> #include <hipcub/hipcub.hpp>
#include "../../runtime/cuda/cuda_common.h" #include "../../runtime/cuda/cuda_common.h"
#include "./utils.h" #include "utils.h"
namespace dgl { namespace dgl {
using runtime::NDArray; using runtime::NDArray;
...@@ -23,7 +26,7 @@ IdArray CumSum(IdArray array, bool prepend_zero) { ...@@ -23,7 +26,7 @@ IdArray CumSum(IdArray array, bool prepend_zero) {
: aten::Full(0, 1, array->dtype.bits, array->ctx); : aten::Full(0, 1, array->dtype.bits, array->ctx);
auto device = runtime::DeviceAPI::Get(array->ctx); auto device = runtime::DeviceAPI::Get(array->ctx);
cudaStream_t stream = runtime::getCurrentCUDAStream(); hipStream_t stream = runtime::getCurrentHIPStreamMasqueradingAsCUDA();
const IdType* in_d = array.Ptr<IdType>(); const IdType* in_d = array.Ptr<IdType>();
IdArray ret; IdArray ret;
IdType* out_d = nullptr; IdType* out_d = nullptr;
...@@ -36,16 +39,15 @@ IdArray CumSum(IdArray array, bool prepend_zero) { ...@@ -36,16 +39,15 @@ IdArray CumSum(IdArray array, bool prepend_zero) {
} }
// Allocate workspace // Allocate workspace
size_t workspace_size = 0; size_t workspace_size = 0;
CUDA_CALL(cub::DeviceScan::InclusiveSum( CUDA_CALL(hipcub::DeviceScan::InclusiveSum(
nullptr, workspace_size, in_d, out_d, len, stream)); nullptr, workspace_size, in_d, out_d, len, stream));
void* workspace = device->AllocWorkspace(array->ctx, workspace_size); void* workspace = device->AllocWorkspace(array->ctx, workspace_size);
// Compute cumsum // Compute cumsum
CUDA_CALL(cub::DeviceScan::InclusiveSum( CUDA_CALL(hipcub::DeviceScan::InclusiveSum(
workspace, workspace_size, in_d, out_d, len, stream)); workspace, workspace_size, in_d, out_d, len, stream));
device->FreeWorkspace(array->ctx, workspace); device->FreeWorkspace(array->ctx, workspace);
return ret; return ret;
} }
......
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