Click here to Skip to main content
15,898,035 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
QuestionUse native C++-DLLs with managed C++ or C#? Pin
Unbe Kant22-May-09 13:26
Unbe Kant22-May-09 13:26 
AnswerRe: Use native C++-DLLs with managed C++ or C#? Pin
N a v a n e e t h23-May-09 5:53
N a v a n e e t h23-May-09 5:53 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Unbe Kant23-May-09 8:09
Unbe Kant23-May-09 8:09 
AnswerRe: Use native C++-DLLs with managed C++ or C#? Pin
Luc Pattyn23-May-09 6:17
sitebuilderLuc Pattyn23-May-09 6:17 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Unbe Kant23-May-09 8:24
Unbe Kant23-May-09 8:24 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Luc Pattyn23-May-09 8:57
sitebuilderLuc Pattyn23-May-09 8:57 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Unbe Kant23-May-09 12:07
Unbe Kant23-May-09 12:07 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Luc Pattyn23-May-09 12:35
sitebuilderLuc Pattyn23-May-09 12:35 
Unbe Kant wrote:
would that be one of those categories?


absolutely not. as I understand it, you have a lot of data (filling almost all the memory)
and a heavy computation, nothing extremely dynamic or real-time oriented.

The one thing you must avoid is having your data copied, since 1) that slows things down, and 2) that requires extra memory (worst case: twice as much).


I still believe allocating on the managed side is the right way to go. I can't imagine Intel insists on allocating the data arrays themselves. They must accept pre-existing arrays, so allocate them in the managed world, use GCHandle to pin them down and get their pointer, then pass that to the native code, where Intel should accept them as if they were allocated with native code outside the Intel library. (If the Intel library would need some working space, which remains entirely hidden from the outside, so be it).

There is one caveat: managed memory blocks larger than some 80-85KB get allocated on the "large-object heap" which never gets compacted (moving the data would be too expensive). If lots of such blocks, all with different sizes, would be allocated and deallocated in random order, memory could become fragmented preventing a future allocation although sufficient free memory is available.

The relevance of a fragmentation risk depends on the variability of your array sizes, and the frequency of allocating and freeing such arrays. The subject is carefully avoided in all but the deepest documentation and discussions.


If, for some reason, you have to allocate all memory on the native side, you will have to:
- either provide managed but pointer-based code to fill the array yourself;
- or rely on one of the Marshal.Copy() overloads to fill part of the arrays (doing it by parts to prevent you needing twice the memory), maybe row-by-row.

BTW: I trust both Intel's library and yourself are sufficiently performance-aware to avoid multi-dimensional arrays; in my experience a little effort to linearize them immediately pays off.

Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Unbe Kant23-May-09 13:22
Unbe Kant23-May-09 13:22 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
led mike27-May-09 5:01
led mike27-May-09 5:01 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
Luc Pattyn27-May-09 5:50
sitebuilderLuc Pattyn27-May-09 5:50 
GeneralRe: Use native C++-DLLs with managed C++ or C#? Pin
N a v a n e e t h27-May-09 17:22
N a v a n e e t h27-May-09 17:22 
QuestionResizing of Labels in Controls Pin
cherrymotion21-May-09 21:23
cherrymotion21-May-09 21:23 
AnswerRe: Resizing of Labels in Controls Pin
N a v a n e e t h21-May-09 21:54
N a v a n e e t h21-May-09 21:54 
GeneralRe: Resizing of Labels in Controls Pin
cherrymotion21-May-09 22:16
cherrymotion21-May-09 22:16 
QuestionRe: Resizing of Labels in Controls Pin
led mike22-May-09 4:26
led mike22-May-09 4:26 
AnswerRe: Resizing of Labels in Controls Pin
cherrymotion22-May-09 8:25
cherrymotion22-May-09 8:25 
GeneralRe: Resizing of Labels in Controls [modified] Pin
Luc Pattyn22-May-09 9:40
sitebuilderLuc Pattyn22-May-09 9:40 
QuestionSending events to main window of another process Pin
parth_patel21-May-09 5:34
parth_patel21-May-09 5:34 
QuestionRe: Sending events to main window of another process Pin
led mike21-May-09 5:48
led mike21-May-09 5:48 
AnswerRe: Sending events to main window of another process Pin
parth_patel21-May-09 6:05
parth_patel21-May-09 6:05 
GeneralRe: Sending events to main window of another process Pin
led mike21-May-09 7:50
led mike21-May-09 7:50 
GeneralRe: Sending events to main window of another process Pin
parth_patel21-May-09 10:58
parth_patel21-May-09 10:58 
GeneralRe: Sending events to main window of another process Pin
parth_patel27-May-09 9:23
parth_patel27-May-09 9:23 
AnswerRe: Sending events to main window of another process Pin
Mark Salsbery21-May-09 7:23
Mark Salsbery21-May-09 7:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.