Intel® oneAPI Threading Building Blocks
Ask questions and share information about adding parallelism to your applications when using this threading library.

scalable_malloc incorrectly enabled?

Daniel_Faken
Beginner
685 Views
Hello,

I'm trying to do some development with TBB (& intel compiler v11.1.060) but currently my program is crashing with some memory problems.
I'm only linking with tbb.dll, not tbbmalloc.dll or tbbmalloc_proxy.dll, but when I set TBB_VERSION to 1 and then run my program I get the following output:

TBB: VERSION 2.2
TBB: INTERFACE VERSION 4002
TBB: BUILD_DATE Wed, 9 Dec 2009 09:42:44 UTC
TBB: BUILD_HOST FXEOWIN16
TBB: BUILD_OS Microsoft Windows [Version 5.2.3790]
TBB: BUILD_CL Microsoft 32-bit C/C++ Optimizing Compiler Version 1
4.00.50727.762 for 80x86
TBB: BUILD_COMPILER Intel C++ Compiler Professional for applications runn
ing on IA-32, Version 11.1 Build 20090903 Package ID: w_cproc_p_11.1.046
TBB: BUILD_TARGET ia32
TBB: BUILD_COMMAND icl /nologo /Qvc8 /MD /O2 /Zi /EHsc /GR /Zc:forScope /Zc
:wchar_t /Oy /DDO_ITT_NOTIFY /DUSE_WINTHREAD /D_CRT_SECURE_NO_DEPRECATE /D_WIN32
_WINNT=0x0400 /D_USE_RTM_VERSION /D__TBB_BUILD=1 /W3 /WX
TBB: TBB_USE_DEBUG 0
TBB: TBB_USE_ASSERT 0
TBB: DO_ITT_NOTIFY 1
TBB: ALLOCATOR scalable_malloc
TBB: RML private
TBB: SCHEDULER Intel

This claims that scalable_malloc is being used, even though I don't see how it could be (per the docs anyway).
Is this incorrect?
I'm wondering if it is somehow interfering with the main memory system, causing my crashes -- though that seems unlikely.

A related question: actually I would like to try the scalable allocator, but my program is loaded as a plugin to python. Is there a way to replace the main allocator without recompiling python?

thanks,
Daniel Faken
0 Kudos
6 Replies
Vladimir_P_1234567890
685 Views
hello Daniel,

"TBB: ALLOCATOR scalable_malloc" means that tbb.dll itself uses scalable allocator. It should not affect otherapplication or runtime libraries. You can try to switch to standard malloc by renaming tbbmalloc.dll which is next to tbb.dll or which can be found in %path%.

You can try to replace scalable allocator in python via plugin by removing "&& reserved" substring from src\tbbmalloc\proxy.cpp file. then you need to rebuild tbbmalloc_proxy.dll and link with it via including tbbmalloc_proxy.h. But this will cause performance degradation on free() calls for memory which was allocated before your pluginis loaded.

--Vladimir
0 Kudos
Daniel_Faken
Beginner
685 Views
Vladimir,

Thank you for this. I have finally (four months later) implemented this.

Is there any way to tell which allocator is being used from my C++ plugin library? I didn't see any noticeable difference in performance.

thanks again,
Daniel Faken
0 Kudos
Alexey-Kukanov
Employee
685 Views
Quoting Daniel Faken
Is there any way to tell which allocator is being used from my C++ plugin library?


Look for tbb_allocator::allocator_type() in tbb_allocator.h.

0 Kudos
Daniel_Faken
Beginner
685 Views
Alexey,

Sorry if that was unclear.
I meant is there a way to tell whether TBB substituted its malloc for the system malloc in all DLLs?

Looking at proxy.cpp, I don't see any obvious way to tell.

Maybe TBB could set a flag indicating it succesfully completed the substitutions?

Daniel
0 Kudos
Vladimir_P_1234567890
685 Views
Hi Daniel,
Look atReplaceFunctionWithStore() function in proxy.cpp. There is printf() to stderr and exit(1) in case required routine was not substituted.
Another option is to set breakpoint in scalable_malloc and look at stack or put a few trace messages to the allocator. Yet another option is to enable traces in allocator. But this might be huge amount of data.
--Vladimir
0 Kudos
Daniel_Faken
Beginner
685 Views
Vladimir,

OK, now I see that RepalceFunctionWithStore() should fail. I think I'll also just put the breakpoint in if I need to, as you suggest.

Thanks for your assistance.

Daniel
0 Kudos
Reply