Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
74d88bf8
Commit
74d88bf8
authored
Feb 20, 2025
by
sangwz
Browse files
Merge branch 'dtk25.04' of
http://developer.sourcefind.cn/codes/OpenDAS/dgl
into 2.2.1
parents
2a1ac588
314cedc1
Changes
179
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
94 additions
and
61 deletions
+94
-61
graphbolt/src/unique_and_compact.cc
graphbolt/src/unique_and_compact.cc
+4
-3
include/dgl/array.h
include/dgl/array.h
+7
-6
include/dgl/array_iterator.h
include/dgl/array_iterator.h
+3
-2
include/dgl/aten/array_ops.h
include/dgl/aten/array_ops.h
+2
-1
include/dgl/aten/coo.h
include/dgl/aten/coo.h
+5
-4
include/dgl/aten/csr.h
include/dgl/aten/csr.h
+5
-4
include/dgl/aten/macro.h
include/dgl/aten/macro.h
+7
-6
include/dgl/aten/spmat.h
include/dgl/aten/spmat.h
+2
-1
include/dgl/base_heterograph.h
include/dgl/base_heterograph.h
+2
-1
include/dgl/bcast.h
include/dgl/bcast.h
+2
-1
include/dgl/graph_interface.h
include/dgl/graph_interface.h
+2
-1
include/dgl/kernel.h
include/dgl/kernel.h
+3
-2
include/dgl/nodeflow.h
include/dgl/nodeflow.h
+2
-1
include/dgl/packed_func_ext.h
include/dgl/packed_func_ext.h
+4
-3
include/dgl/runtime/c_object_api.h
include/dgl/runtime/c_object_api.h
+2
-1
include/dgl/runtime/c_runtime_api.h
include/dgl/runtime/c_runtime_api.h
+3
-1
include/dgl/runtime/device_api.h
include/dgl/runtime/device_api.h
+4
-3
include/dgl/runtime/module.h
include/dgl/runtime/module.h
+1
-0
include/dgl/runtime/ndarray.h
include/dgl/runtime/ndarray.h
+24
-11
include/dgl/runtime/tensordispatch.h
include/dgl/runtime/tensordispatch.h
+10
-9
No files found.
graphbolt/src/unique_and_compact.cc
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2023 by Contributors
*
...
...
@@ -10,9 +11,9 @@
#include <unordered_map>
#include "
./
concurrent_id_hash_map.h"
#include "
./
macro.h"
#include "
./
utils.h"
#include "concurrent_id_hash_map.h"
#include "macro.h"
#include "utils.h"
namespace
graphbolt
{
namespace
sampling
{
...
...
include/dgl/array.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020 by Contributors
* @file dgl/array.h
...
...
@@ -8,10 +9,10 @@
*/
#ifndef DGL_ARRAY_H_
#define DGL_ARRAY_H_
#include "
./
aten/array_ops.h"
#include "
./
aten/coo.h"
#include "
./
aten/csr.h"
#include "
./
aten/macro.h"
#include "
./
aten/spmat.h"
#include "
./
aten/types.h"
#include "aten/array_ops.h"
#include "aten/coo.h"
#include "aten/csr.h"
#include "aten/macro.h"
#include "aten/spmat.h"
#include "aten/types.h"
#endif // DGL_ARRAY_H_
include/dgl/array_iterator.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020 by Contributors
* @file dgl/array_iterator.h
...
...
@@ -6,11 +7,11 @@
#ifndef DGL_ARRAY_ITERATOR_H_
#define DGL_ARRAY_ITERATOR_H_
#ifdef __
CUDA_ARCH
__
#ifdef __
HIPCC
__
#define CUB_INLINE __host__ __device__ __forceinline__
#else
#define CUB_INLINE inline
#endif // __
CUDA_ARCH
__
#endif // __
HIP_DEVICE_COMPILE
__
#include <algorithm>
#include <iterator>
...
...
include/dgl/aten/array_ops.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020 by Contributors
* @file dgl/aten/array_ops.h
...
...
@@ -15,7 +16,7 @@
#include <utility>
#include <vector>
#include "
./
types.h"
#include "types.h"
namespace
dgl
{
namespace
aten
{
...
...
include/dgl/aten/coo.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020-2022 by Contributors
...
...
@@ -15,10 +16,10 @@
#include <utility>
#include <vector>
#include "
./
array_ops.h"
#include "
./
macro.h"
#include "
./
spmat.h"
#include "
./
types.h"
#include "array_ops.h"
#include "macro.h"
#include "spmat.h"
#include "types.h"
namespace
dgl
{
namespace
aten
{
...
...
include/dgl/aten/csr.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020-2022 by Contributors
* @file dgl/aten/csr.h
...
...
@@ -14,10 +15,10 @@
#include <utility>
#include <vector>
#include "
./
array_ops.h"
#include "
./
macro.h"
#include "
./
spmat.h"
#include "
./
types.h"
#include "array_ops.h"
#include "macro.h"
#include "spmat.h"
#include "types.h"
namespace
dgl
{
namespace
aten
{
...
...
include/dgl/aten/macro.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020 by Contributors
* @file dgl/aten/macro.h
...
...
@@ -47,7 +48,7 @@
if ((val) == kDGLCPU) { \
constexpr auto XPU = kDGLCPU; \
{ __VA_ARGS__ } \
} else if ((val) == kDGLCUDA) { \
} else if ((val) == kDGLCUDA
or (val) == kDGLROCM
) { \
constexpr auto XPU = kDGLCUDA; \
{ __VA_ARGS__ } \
} else { \
...
...
@@ -145,12 +146,12 @@
typedef double FloatType; \
{ __VA_ARGS__ } \
} else if ( \
XPU == kDGLCUDA &&
(val).bits == 16 && (val).code == kDGLFloat) { \
(
XPU == kDGLCUDA
|| XPU == kDGLROCM)
&&(val).bits == 16 && (val).code == kDGLFloat) { \
typedef __half FloatType; \
{ __VA_ARGS__ } \
} else if ( \
XPU == kDGLCUDA && (val).bits == 16 && (val).code == kDGLBfloat) { \
typedef __
nv
_bfloat16 FloatType; \
(
XPU == kDGLCUDA
|| XPU == kDGLROCM)
&& (val).bits == 16 && (val).code == kDGLBfloat) { \
typedef __
hip
_bfloat16 FloatType; \
{ __VA_ARGS__ } \
} else if ( \
XPU == kDGLCPU && (val).bits == 16 && (val).code == kDGLFloat) { \
...
...
@@ -176,11 +177,11 @@
typedef double FloatType; \
{ __VA_ARGS__ } \
} else if ( \
XPU == kDGLCUDA && (val).bits == 16 && (val).code == kDGLFloat) { \
(
XPU == kDGLCUDA
|| XPU == kDGLROCM)
&& (val).bits == 16 && (val).code == kDGLFloat) { \
typedef __half FloatType; \
{ __VA_ARGS__ } \
} else if ( \
XPU == kDGLCUDA && (val).bits == 16 && (val).code == kDGLBfloat) { \
(
XPU == kDGLCUDA
|| XPU == kDGLROCM)
&& (val).bits == 16 && (val).code == kDGLBfloat) { \
LOG(FATAL) << "bfloat16 requires CUDA >= 11.0"; \
} else if ( \
XPU == kDGLCPU && (val).bits == 16 && (val).code == kDGLFloat) { \
...
...
include/dgl/aten/spmat.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020 by Contributors
* @file dgl/aten/spmat.h
...
...
@@ -10,7 +11,7 @@
#include <vector>
#include "../runtime/object.h"
#include "
./
types.h"
#include "types.h"
namespace
dgl
{
...
...
include/dgl/base_heterograph.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2019 by Contributors
* @file dgl/heterograph_interface.h
...
...
@@ -13,7 +14,7 @@
#include <utility>
#include <vector>
#include "
./
runtime/object.h"
#include "runtime/object.h"
#include "array.h"
#include "aten/spmat.h"
#include "aten/types.h"
...
...
include/dgl/bcast.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020 by Contributors
* @file dgl/aten/bcast.h
...
...
@@ -9,7 +10,7 @@
#include <string>
#include <vector>
#include "
./
runtime/ndarray.h"
#include "runtime/ndarray.h"
using
namespace
dgl
::
runtime
;
namespace
dgl
{
...
...
include/dgl/graph_interface.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2018 by Contributors
* @file dgl/graph_interface.h
...
...
@@ -12,7 +13,7 @@
#include <utility>
#include <vector>
#include "
./
runtime/object.h"
#include "runtime/object.h"
#include "array.h"
namespace
dgl
{
...
...
include/dgl/kernel.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020 by Contributors
* @file dgl/aten/kernel.h
...
...
@@ -10,8 +11,8 @@
#include <utility>
#include <vector>
#include "
./
base_heterograph.h"
#include "
./
bcast.h"
#include "base_heterograph.h"
#include "bcast.h"
#include "array.h"
namespace
dgl
{
...
...
include/dgl/nodeflow.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2019 by Contributors
* @file dgl/nodeflow.h
...
...
@@ -10,7 +11,7 @@
#include <string>
#include <vector>
#include "
./
runtime/object.h"
#include "runtime/object.h"
#include "graph_interface.h"
namespace
dgl
{
...
...
include/dgl/packed_func_ext.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2019 by Contributors
* @file packed_func_ext.h
...
...
@@ -12,9 +13,9 @@
#include <string>
#include <type_traits>
#include "
./
runtime/container.h"
#include "
./
runtime/object.h"
#include "
./
runtime/packed_func.h"
#include "runtime/container.h"
#include "runtime/object.h"
#include "runtime/packed_func.h"
namespace
dgl
{
namespace
runtime
{
...
...
include/dgl/runtime/c_object_api.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2019 by Contributors
* @file dgl/runtime/c_object_api.h
...
...
@@ -10,7 +11,7 @@
#ifndef DGL_RUNTIME_C_OBJECT_API_H_
#define DGL_RUNTIME_C_OBJECT_API_H_
#include "
./
c_runtime_api.h"
#include "c_runtime_api.h"
#ifdef __cplusplus
extern
"C"
{
...
...
include/dgl/runtime/c_runtime_api.h
View file @
74d88bf8
...
...
@@ -35,6 +35,7 @@
// DGL version
#define DGL_VERSION "2.2.1"
#ifdef __cplusplus
extern
"C"
{
#endif
...
...
@@ -55,7 +56,8 @@ typedef enum {
/** @brief CPU device */
kDGLCPU
=
1
,
/** @brief CUDA GPU device */
kDGLCUDA
=
2
,
kDGLCUDA
=
10
,
kDGLROCM
=
2
,
// add more devices once supported
}
DGLDeviceType
;
...
...
include/dgl/runtime/device_api.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2016 by Contributors
* @file dgl/runtime/device_api.h
...
...
@@ -174,7 +175,7 @@ class DeviceAPI {
DGLContext
ctx
,
DGLStreamHandle
event_src
,
DGLStreamHandle
event_dst
);
/**
* @brief Pin host memory using
cuda
HostRegister().
* @brief Pin host memory using
hip
HostRegister().
*
* @param ptr The host memory pointer to be pinned.
* @param nbytes The size to be pinned.
...
...
@@ -183,7 +184,7 @@ class DeviceAPI {
DGL_DLL
virtual
bool
PinData
(
void
*
ptr
,
size_t
nbytes
);
/**
* @brief Unpin host memory using
cuda
HostUnregister().
* @brief Unpin host memory using
hip
HostUnregister().
*
* @param ptr The host memory pointer to be unpinned.
*/
...
...
@@ -203,7 +204,7 @@ class DeviceAPI {
/**
* @brief 'Deallocate' the pinned memory from PyTorch CachingHostAllocator.
* @note It avoids unnecessary
cudaFreeHost
calls and puts the memory
* @note It avoids unnecessary
hipHostFree
calls and puts the memory
* block into CachingHostAllocator's free list.
* @param deleter Pointer to the deleter function from PyTorch's
* CachingHostAllocator.
...
...
include/dgl/runtime/module.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2017 by Contributors
* @file dgl/runtime/module.h
...
...
include/dgl/runtime/ndarray.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2017-2022 by Contributors
* @file dgl/runtime/ndarray.h
...
...
@@ -18,13 +19,20 @@
#include "shared_mem.h"
#ifdef DGL_USE_CUDA
#include <
cuda
_runtime.h>
#include <
hip/hip
_runtime.h>
#define BF16_ENABLED (defined(CUDART_VERSION) && CUDART_VERSION >= 11000)
// #define BF16_ENABLED (defined(DTKRT_VERSION) && DTKRT_VERSION >= 11000)
#if defined(DTKRT_VERSION)
#define DTKRT_VERSION_CHECK (DTKRT_VERSION >= 11000)
#else
#define DTKRT_VERSION_CHECK 0
#endif
#include <cuda_fp16.h>
#define BF16_ENABLED DTKRT_VERSION_CHECK
#include <hip/hip_fp16.h>
#if BF16_ENABLED
#include <
cuda
_bf16.h>
#include <
hip/hip
_bf16.h>
#endif // BF16_ENABLED
#endif // DGL_USE_CUDA
...
...
@@ -60,7 +68,7 @@ GEN_DGLDATATYPETRAITS_FOR(uint64_t, kDGLInt, 64);
#ifdef DGL_USE_CUDA
GEN_DGLDATATYPETRAITS_FOR
(
__half
,
kDGLFloat
,
16
);
#if BF16_ENABLED
GEN_DGLDATATYPETRAITS_FOR
(
__
nv
_bfloat16
,
kDGLBfloat
,
16
);
GEN_DGLDATATYPETRAITS_FOR
(
__
hip
_bfloat16
,
kDGLBfloat
,
16
);
#endif // BF16_ENABLED
#endif // DGL_USE_CUDA
GEN_DGLDATATYPETRAITS_FOR
(
float
,
kDGLFloat
,
32
);
...
...
@@ -185,7 +193,7 @@ class NDArray {
* CachingHostAllocator for allocating pinned memory and copying data
* from the current NDAarray. As a result, PyTorch is responsible for
* managing the lifecycle of the returned NDArray, including deciding
* when to flush the data for reuse or call
cudaFreeHost
. The current
* when to flush the data for reuse or call
hipHostFree
. The current
* context must be kDGLCPU, otherwise, an error will be thrown.
*/
inline
NDArray
PinMemory
();
...
...
@@ -194,7 +202,7 @@ class NDArray {
* @brief In-place method to pin the current array by calling PinContainer
* on the underlying NDArray:Container.
* @note This is an in-place method that flags the memory as page-locked by
* utilizing
cuda
HostRegister at the underlying level to pin the current
* utilizing
hip
HostRegister at the underlying level to pin the current
* instance of NDArray. The current context must be kDGLCPU, otherwise,
* an error will be thrown.
*/
...
...
@@ -523,7 +531,7 @@ inline void NDArray::CopyFrom(const NDArray& other) {
// Pinned by PyTorch
if
(
cpu_data
->
pinned_by_pytorch_
)
{
// To ensure correct behavior, the event must be recorded after
//
cuda
MemcpyAsync as long as the memory is pinned by PyTorch.
//
hip
MemcpyAsync as long as the memory is pinned by PyTorch.
void
*
pytorch_ctx
=
cpu_data
->
pytorch_ctx_
;
RecordedCopyFromTo
(
&
(
other
.
data_
->
dl_tensor
),
&
(
data_
->
dl_tensor
),
pytorch_ctx
);
...
...
@@ -549,7 +557,7 @@ inline void NDArray::CopyTo(const NDArray& other) const {
// pinned by PyTorch
if
(
cpu_data
->
pinned_by_pytorch_
)
{
// To ensure correct behavior, the event must be recorded after
//
cuda
MemcpyAsync as long as the memory is pinned by PyTorch.
//
hip
MemcpyAsync as long as the memory is pinned by PyTorch.
void
*
pytorch_ctx
=
cpu_data
->
pytorch_ctx_
;
RecordedCopyFromTo
(
&
(
data_
->
dl_tensor
),
&
(
other
.
data_
->
dl_tensor
),
pytorch_ctx
);
...
...
@@ -716,6 +724,8 @@ inline const char* DeviceTypeCode2Str(DGLDeviceType device_type) {
return
"cpu"
;
case
kDGLCUDA
:
return
"cuda"
;
case
kDGLROCM
:
return
"cuda"
;
default:
LOG
(
FATAL
)
<<
"Unsupported device type code="
<<
static_cast
<
int
>
(
device_type
);
...
...
@@ -871,8 +881,11 @@ inline std::ostream& operator<<(std::ostream& os, DGLDataType t) {
/** @brief Check whether two device contexts are the same.*/
inline
bool
operator
==
(
const
DGLContext
&
ctx1
,
const
DGLContext
&
ctx2
)
{
return
ctx1
.
device_type
==
ctx2
.
device_type
&&
ctx1
.
device_id
==
ctx2
.
device_id
;
// printf("**************** debug compare DGLContext, %d, %d\n",ctx1.device_type,ctx2.device_type);
int
ct1
=
ctx1
.
device_type
==
10
?
2
:
ctx1
.
device_type
;
int
ct2
=
ctx2
.
device_type
==
10
?
2
:
ctx2
.
device_type
;
return
ct1
==
ct2
&&
int
(
ctx1
.
device_id
)
==
int
(
ctx2
.
device_id
);
}
/** @brief Check whether two device contexts are different.*/
...
...
include/dgl/runtime/tensordispatch.h
View file @
74d88bf8
// !!! This is a file automatically generated by hipify!!!
/**
* Copyright (c) 2020-2022 by Contributors
* @file array/tensordispatch.h
...
...
@@ -34,7 +35,7 @@
#include <windows.h>
#endif // WIN32
#ifdef DGL_USE_CUDA
#include <
cuda
_runtime.h>
#include <
hip/hip
_runtime.h>
#endif // DGL_USE_CUDA
#include "ndarray.h"
...
...
@@ -97,14 +98,14 @@ class TensorDispatcher {
* Used in CUDADeviceAPI::AllocWorkspace().
*
* @note THCCachingAllocator specify the device to allocate on
* via
cuda
GetDevice(). Make sure to call
cuda
SetDevice()
* via
hip
GetDevice(). Make sure to call
hip
SetDevice()
* before invoking this function.
*
* @param nbytes The size to be allocated.
* @param stream The stream to be allocated on.
* @return Pointer to the allocated memory.
*/
inline
void
*
CUDAAllocWorkspace
(
size_t
nbytes
,
cuda
Stream_t
stream
)
{
inline
void
*
CUDAAllocWorkspace
(
size_t
nbytes
,
hip
Stream_t
stream
)
{
auto
entry
=
entrypoints_
[
Op
::
kCUDARawAlloc
];
return
FUNCCAST
(
tensoradapter
::
CUDARawAlloc
,
entry
)(
nbytes
,
stream
);
}
...
...
@@ -122,15 +123,15 @@ class TensorDispatcher {
/**
* @brief Find the current PyTorch CUDA stream
* Used in runtime::getCurrent
CUDA
Stream().
* Used in runtime::getCurrent
HIP
Stream
MasqueradingAsCUDA
().
*
* @note PyTorch pre-allocates/sets the current CUDA stream
* on current device via
cuda
GetDevice(). Make sure to call
cuda
SetDevice()
* on current device via
hip
GetDevice(). Make sure to call
hip
SetDevice()
* before invoking this function.
*
* @return
cuda
Stream_t stream handle
* @return
hip
Stream_t stream handle
*/
inline
cuda
Stream_t
CUDAGetCurrentStream
()
{
inline
hip
Stream_t
CUDAGetCurrentStream
()
{
auto
entry
=
entrypoints_
[
Op
::
kCUDACurrentStream
];
return
FUNCCAST
(
tensoradapter
::
CUDACurrentStream
,
entry
)();
}
...
...
@@ -183,7 +184,7 @@ class TensorDispatcher {
* @param device_id Device of the tensor.
*/
inline
void
CUDARecordHostAlloc
(
void
*
data
,
void
*
ctx
,
cuda
Stream_t
stream
,
int
device_id
)
{
void
*
data
,
void
*
ctx
,
hip
Stream_t
stream
,
int
device_id
)
{
auto
entry
=
entrypoints_
[
Op
::
kCUDARecordHostAlloc
];
auto
recorded_alloc
=
FUNCCAST
(
tensoradapter
::
CUDARecordHostAlloc
,
entry
);
recorded_alloc
(
data
,
ctx
,
stream
,
device_id
);
...
...
@@ -212,7 +213,7 @@ class TensorDispatcher {
#ifdef DGL_USE_CUDA
auto
entry
=
entrypoints_
[
Op
::
kRecordStream
];
FUNCCAST
(
tensoradapter
::
RecordStream
,
entry
)
(
ptr
,
static_cast
<
cuda
Stream_t
>
(
stream
),
device_id
);
(
ptr
,
static_cast
<
hip
Stream_t
>
(
stream
),
device_id
);
#endif
}
...
...
Prev
1
2
3
4
5
6
7
…
9
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment