File tree 1 file changed +11
-3
lines changed
paddle/fluid/distributed/common
1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 14
14
15
15
#pragma once
16
16
#include < glog/logging.h>
17
+ #include " paddle/fluid/platform/enforce.h"
17
18
18
19
namespace paddle {
19
20
namespace distributed {
@@ -77,9 +78,16 @@ class ChunkAllocator {
77
78
78
79
void create_new_chunk () {
79
80
Chunk* chunk;
80
- posix_memalign (reinterpret_cast <void **>(&chunk),
81
- std::max<size_t >(sizeof (void *), alignof (Chunk)),
82
- sizeof (Chunk) + sizeof (Node) * _chunk_size);
81
+ size_t alloc_size = sizeof (Chunk) + sizeof (Node) * _chunk_size;
82
+ int error = posix_memalign (reinterpret_cast <void **>(&chunk),
83
+ std::max<size_t >(sizeof (void *), alignof (Chunk)),
84
+ alloc_size);
85
+ PADDLE_ENFORCE_EQ (error,
86
+ 0 ,
87
+ paddle::platform::errors::ResourceExhausted (
88
+ " Fail to alloc memory of %ld size, error code is %d." ,
89
+ alloc_size,
90
+ error));
83
91
chunk->next = _chunks;
84
92
_chunks = chunk;
85
93
You can’t perform that action at this time.
0 commit comments