MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / rmm_wrap_allocate

Function rmm_wrap_allocate

deps/GraphBLAS/rmm_wrap/rmm_wrap.cpp:375–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373//------------------------------------------------------------------------------
374
375void *rmm_wrap_allocate( std::size_t *size)
376{
377 if (rmm_wrap_context == NULL) return (NULL) ;
378
379 alloc_map *am = rmm_wrap_context->size_map.get() ;
380 if (am == NULL)
381 {
382 // PANIC!
383 // std::cout<< "Uh oh, can't allocate before initializing RMM"
384 // << std::endl;
385 return (NULL) ;
386 }
387
388 // ensure size is nonzero
389 if (*size == 0) *size = 256 ;
390 // round-up the allocation to a multiple of 256
391 std::size_t aligned = (*size) % 256 ;
392 if (aligned > 0)
393 {
394 *size += (256 - aligned) ;
395 }
396
397// printf(" rmm_wrap_alloc %ld bytes\n",*size) ;
398
399
400 rmm::mr::device_memory_resource *memoryresource =
401 rmm::mr::get_current_device_resource() ;
402 void *p = memoryresource->allocate( *size ) ;
403 if (p == NULL)
404 {
405 // out of memory
406 *size = 0 ;
407 return (NULL) ;
408 }
409
410 // insert p into the hashmap
411 am->emplace ((std::size_t)p, (std::size_t)(*size)) ;
412
413 // return the allocated block
414 return (p) ;
415}
416
417//------------------------------------------------------------------------------
418// rmm_wrap_deallocate: deallocate a block previously allocated by RMM

Callers 5

rmm_wrap_mallocFunction · 0.85
rmm_wrap_callocFunction · 0.85
rmm_wrap_reallocFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by 2

mainFunction · 0.68
mainFunction · 0.68