MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / AlignedMalloc

Function AlignedMalloc

tensorflow/core/platform/posix/port.cc:241–258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241void* AlignedMalloc(size_t size, int minimum_alignment) {
242#if defined(__ANDROID__)
243 return memalign(minimum_alignment, size);
244#else // !defined(__ANDROID__)
245 void* ptr = nullptr;
246 // posix_memalign requires that the requested alignment be at least
247 // sizeof(void*). In this case, fall back on malloc which should return
248 // memory aligned to at least the size of a pointer.
249 const int required_alignment = sizeof(void*);
250 if (minimum_alignment < required_alignment) return Malloc(size);
251 int err = posix_memalign(&ptr, minimum_alignment, size);
252 if (err != 0) {
253 return nullptr;
254 } else {
255 return ptr;
256 }
257#endif
258}
259
260void AlignedFree(void* aligned_memory) { Free(aligned_memory); }
261

Callers 15

NUMAMallocFunction · 0.70
AllocateRawMethod · 0.50
SetPieceMethod · 0.50
GetMemBlockMethod · 0.50
TensorMethod · 0.50
AllocateRawMethod · 0.50
AllocateRawMethod · 0.50
AllocMethod · 0.50
AllocMethod · 0.50
AllocCuptiActivityBufferFunction · 0.50
operator new[]Method · 0.50
ArenaMethod · 0.50

Calls 1

MallocFunction · 0.70

Tested by 1

TESTFunction · 0.40