www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Compiling nedmalloc w/ DMC

reply "Craig Black" <cblack ara.com> writes:
I know some D users are interested in nedmalloc so I thought I would post
this here as well as in the C++ newsgroup.  BTW, I am very impressed with
nedmalloc.  In my C++ code, I gained an overall performance increase of
about 15% by using it.

I've been talking with Niall Douglas, the author of nedmalloc about my
problems with compiling it using DMC.  He says the libraries are outdated.
In addition to the problem posted below, it seems that DMC's kernel32.lib
does not include the required functions TryEnterCriticalSection and
Initialize CriticalSectionAndSpinCount.

On 5 Jan 2007 at 11:33, Craig Black wrote:

 Sorry I didn't respond sooner. Someone told me that it didn't compile

 DMC, so to verify I had to find the time to try it myself. nedmalloc.c

 compile, but test.c does not. It could be a problem with the Digital Mars

 compiler. Perhaps if we can figure out what the bug is, we can report it.

 maybe there is a quick fix that you could implement to get it working.
 Here's the error messages I get.

 C:\nedmalloc>..\dm\bin\dmc test.c -w -c
 HeapSetInformation(win32heap, HeapCompatibilityInformation,
 &data, sizeof(data));
 ^
 test.c(228) : Error: undefined identifier 'HeapCompatibilityInformation'
 --- errorlevel 1

 Thanks in advance.

Heh, that's dirt easy! Your friend is using an old SDK which isn't defining HeapCompatibilityInformation. He can upgrade it, or else substitute 0 for it. See http://msdn2.microsoft.com/en- us/library/aa366705.aspx. Cheers, Niall
Jan 05 2007
next sibling parent reply "Craig Black" <cblack ara.com> writes:
 In addition to the problem posted below, it seems that DMC's kernel32.lib
 does not include the required functions TryEnterCriticalSection and
 InitializeCriticalSectionAndSpinCount.

After talking with Niall some more, we found that we could get rid of the TryEnterCriticalSection link error by adding the line #define _WIN32_WINNT 0x403 before #include <windows.h> Curiosly, this did not fix the link error with InitializeCriticalSectionAndSpinCount. After further investigation, I found that both are found in DMC's kernel32.lib. Perhaps the function parameters are different. I still think DMC may need to upgrade it's libraries. Anyone have any other ideas? -Craig
Jan 05 2007
parent Sean Kelly <sean f4.ca> writes:
Craig Black wrote:
 In addition to the problem posted below, it seems that DMC's kernel32.lib
 does not include the required functions TryEnterCriticalSection and
 InitializeCriticalSectionAndSpinCount.

After talking with Niall some more, we found that we could get rid of the TryEnterCriticalSection link error by adding the line #define _WIN32_WINNT 0x403 before #include <windows.h> Curiosly, this did not fix the link error with InitializeCriticalSectionAndSpinCount. After further investigation, I found that both are found in DMC's kernel32.lib. Perhaps the function parameters are different. I still think DMC may need to upgrade it's libraries. Anyone have any other ideas?

I'm not sure if this helps, but VC8 declares this function in WinBase.h like so: #if (_WIN32_WINNT >= 0x0403) WINBASEAPI BOOL WINAPI InitializeCriticalSectionAndSpinCount( __out LPCRITICAL_SECTION lpCriticalSection, __in DWORD dwSpinCount ); Sean
Jan 05 2007
prev sibling parent reply zz <zz zz.com> writes:
Craig Black wrote:
 I know some D users are interested in nedmalloc so I thought I would post
 this here as well as in the C++ newsgroup.  BTW, I am very impressed with
 nedmalloc.  In my C++ code, I gained an overall performance increase of
 about 15% by using it.
 

Here is a dirty solution for compiling nedmalloc with DMC. Inside winnt.h add the following: typedef enum _HEAP_INFORMATION_CLASS { HeapCompatibilityInformation } HEAP_INFORMATION_CLASS; Inside winbase.h add the following: WINBASEAPI BOOL WINAPI InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION,DWORD); compile dmc -o -DNDEBUG -DWIN32 -D_WIN32_WINNT=0x0501 test.c I commented out the if(0) and if(1) in test.c just for my test. And here are my results. Standard DMC allocator: 624583.696090 ops/sec under 2 threads. Nedmalloc allocator: 3109062.452439 ops/sec under 2 threads. Nedmalloc is 4.977816 times faster than standard. Zz
Jan 08 2007
parent reply Georg Wrede <georg nospam.org> writes:
zz wrote:
 Craig Black wrote:
 
 I know some D users are interested in nedmalloc so I thought I would post
 this here as well as in the C++ newsgroup.  BTW, I am very impressed with
 nedmalloc.  In my C++ code, I gained an overall performance increase of
 about 15% by using it.

Here is a dirty solution for compiling nedmalloc with DMC. Inside winnt.h add the following: typedef enum _HEAP_INFORMATION_CLASS { HeapCompatibilityInformation } HEAP_INFORMATION_CLASS; Inside winbase.h add the following: WINBASEAPI BOOL WINAPI InitializeCriticalSectionAndSpinCount(LPCRITICAL_SECTION,DWORD); compile dmc -o -DNDEBUG -DWIN32 -D_WIN32_WINNT=0x0501 test.c I commented out the if(0) and if(1) in test.c just for my test. And here are my results. Standard DMC allocator: 624583.696090 ops/sec under 2 threads. Nedmalloc allocator: 3109062.452439 ops/sec under 2 threads. Nedmalloc is 4.977816 times faster than standard.

I' love to see the results of some wider tests between these two. Does there exist a "de facto standard or standard-like test for memory handling in C-like languages"?
Jan 08 2007
parent zz <zz zz.com> writes:
Georg Wrede wrote:
 zz wrote:
 
 I' love to see the results of some wider tests between these two.
 
 Does there exist a "de facto standard or standard-like test for memory 
 handling in C-like languages"?

Just download nedmalloc from http://www.nedprod.com/programs/portable/nedmalloc/index.html and try it out with your c/c++ compiler, the test.c is included in the download. Zz
Jan 09 2007