File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
paddle/fluid/distributed/common Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1414
1515#pragma once
1616#include < glog/logging.h>
17+ #include " paddle/fluid/platform/enforce.h"
1718
1819namespace paddle {
1920namespace distributed {
@@ -77,9 +78,16 @@ class ChunkAllocator {
7778
7879 void create_new_chunk () {
7980 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));
8391 chunk->next = _chunks;
8492 _chunks = chunk;
8593
You can’t perform that action at this time.
0 commit comments