Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

TBB's Dynamic Memory Interface Replacement in offloaded code

John_F_1
Beginner
953 Views

I would like to try replacing the memory allocator with TBB's scalable memory allocator as detailed here:

http://www.threadingbuildingblocks.org/docs/help/tbb_userguide/Automically_Replacing_malloc.htm

I would like to do this for allocations in offload regions.  This is on windows.  What I've tried:

1) Adding 

  • tbbmalloc_proxy.lib /INCLUDE:"__TBB_malloc_proxy"

to the link line.  This clearly only affects the host allocations

2) Adding

-ltbbmalloc_proxy -ltbbmalloc

to the offload linker options. I also had to copy the .so's to the MIC and put them in /usr/lib64.

Memory allocation still seems to be slow, although I'm not sure how to definitively tell if I'm actually using the TBB allocator.  Is there anything else that I need to do?

0 Kudos
1 Reply
Alexei_K_Intel
Employee
953 Views

It turned out so that the TBB proxy overload approach works only on Windows and Linux but not in offload. Thus you cannot replace standard allocator with TBB allocator via TBB proxy overload in offload. I am not familiar to the offload execution model very much but the root cause is that by the moment offload module starts (and TBB proxy library is loaded) a standard allocator is already loaded and it is too late to overload malloc/free symbols.

The most reliable way to enable TBB allocator in your offload application is replacing malloc/free with scalable_malloc/scalable_free in your code. E.g.

#define malloc(size) scalable_malloc(size)
#define free(ptr) scalable_free(ptr)

Regards, Alex

 

.

0 Kudos
Reply