Skip to content

Commit a38f7dc

Browse files
committed
fix rocm build
1 parent a52d8b6 commit a38f7dc

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

paddle/fluid/memory/allocation/allocator_facade.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,9 +897,11 @@ class AllocatorFacadePrivate {
897897
}
898898

899899
void InitCUDAMallocAsyncAllocator(phi::GPUPlace p, gpuStream_t stream) {
900+
#ifdef PADDLE_WITH_CUDA
900901
std::shared_ptr<Allocator>& allocator = cuda_allocators_[p][stream];
901902
cuda_allocators_[p][stream] =
902903
std::make_shared<CUDAMallocAsyncAllocator>(allocator, p, stream);
904+
#endif
903905
}
904906

905907
void InitAutoGrowthCUDAAllocator(phi::GPUPlace p, gpuStream_t stream) {
@@ -1169,6 +1171,7 @@ class AllocatorFacadePrivate {
11691171
}
11701172

11711173
void WrapCUDAMallocAsyncAllocatorForDefault() {
1174+
#ifdef PADDLE_WITH_CUDA
11721175
for (auto& pair : allocators_) {
11731176
auto& place = pair.first;
11741177
if (platform::is_gpu_place(place)) {
@@ -1188,6 +1191,7 @@ class AllocatorFacadePrivate {
11881191
<< ", allocator address = " << pair.second.get();
11891192
}
11901193
}
1194+
#endif
11911195
}
11921196

11931197
void WrapCUDARetryAllocator(phi::GPUPlace p,

paddle/fluid/memory/allocation/cuda_malloc_async_allocator.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,14 @@
2424
#ifdef PADDLE_WITH_CUDA
2525
#include <cuda.h>
2626
#include <cuda_runtime.h>
27+
#include "paddle/phi/backends/gpu/cuda/cuda_graph.h"
2728
#endif
2829

2930
#include <string>
3031

3132
#include "paddle/fluid/platform/cuda_device_guard.h"
3233
#include "paddle/fluid/platform/device/gpu/gpu_info.h"
3334
#include "paddle/fluid/platform/enforce.h"
34-
#if defined(PADDLE_WITH_CUDA)
35-
#include "paddle/phi/backends/gpu/cuda/cuda_graph.h"
36-
#elif defined(PADDLE_WITH_HIP)
37-
#include "paddle/phi/backends/gpu/rocm/hip_graph.h"
38-
#endif
3935

4036
#include "paddle/utils/optional.h"
4137

paddle/fluid/memory/allocation/cuda_malloc_async_allocator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace allocation {
3737
// managing memory allocations with CUDA async malloc. It includes methods to
3838
// handle stream associations and to query the owning stream of the allocation.
3939
class CUDAMallocAsyncAllocation : public Allocation {
40+
#ifdef PADDLE_WITH_CUDA
4041
public:
4142
CUDAMallocAsyncAllocation(void* ptr,
4243
size_t size,
@@ -60,12 +61,14 @@ class CUDAMallocAsyncAllocation : public Allocation {
6061

6162
SpinLock recorded_streams_lock_;
6263
std::unordered_set<gpuStream_t> recorded_streams_;
64+
#endif
6365
};
6466

6567
// The `CUDAMallocAsyncAllocator` class extends `Allocator` and is specialized
6668
// for asynchronous memory allocation in CUDA. It offers thread-safe allocation
6769
// and incorporates a default stream for memory operations.
6870
class CUDAMallocAsyncAllocator : public Allocator {
71+
#ifdef PADDLE_WITH_CUDA
6972
public:
7073
explicit CUDAMallocAsyncAllocator(
7174
std::shared_ptr<Allocator> underlying_allocator,
@@ -128,6 +131,7 @@ class CUDAMallocAsyncAllocator : public Allocator {
128131
std::unordered_map<CUDAMallocAsyncAllocation*, CUDAGraphID>
129132
graph_owned_allocations_;
130133
SpinLock graph_owned_allocations_lock_;
134+
#endif
131135
};
132136

133137
} // namespace allocation

0 commit comments

Comments
 (0)