473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

#pragma unmanaged

Hi,

I am working on a mixed native/managed project involving DirectShow and am
trying to decide how the modules should be partitioned. I am trying to
understand the true affect of #pragma unmanaged in a managed project. From my
research it seems that, assuming there are no managed/native thunks involved,
the code should perform as though it were compiled in a native Win32 project.
However, as a simple test, I created a project that builds a simple graph
and does some limited frame processing using a sample grabber. I put #pragma
unmanaged at the top of *every* file and compiled it as a managed project.
With the /clr switch there is dramatic performance degradation. With no
managed code at all in this project, I don't understand why. Do the COM calls
in unmanaged code still go through Interop?

Any explanation/insight would be appriciated.
Nov 17 '05 #1
4 3611
Here http://msdn.microsoft.com/msdnmag/issues/05/01/CQA/, Paul DiLascia
described a method to ensure which parts of your application compiles as
managed and which as native.

Here http://msdn.microsoft.com/msdnmag/is...Optimizations/, there
is information about how to get the best perfomance when calling native code
from managed. Read the section titled 'Native and Managed Code in a Single
Image'

--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org
Nov 17 '05 #2
Thanks for the references. I had read Kang's "Power your app..." article.
The primary tip is avoiding or minimizing thunking - especially double
thunking. Given that there are no managed calls in my app and all code is
compiled under #pragma unmanaged directives, I would not expect any thunking
to occur.

Paul's article has some good tips on how to omit modules from being /clr
compiled, which I'm sure I'll use, but I'm still confused about the true
affect of #pragma unmanaged when compiled with /clr.

If all of my code is compiled under that directive and there are is
absolutely no managed code in the project, shouldn't performance be close to
native? I got an email response from a person that suggested several C++
optimizations are disabled when compiled with /clr. But the performance
difference is substantial - more than I would attribute to optimizations, or
lack thereof.

Thanks for your help. I'm not trying to be stubborn - just trying to
understand.

- Troy

----------
"Rodrigo Corral [MVP]" wrote:
Here http://msdn.microsoft.com/msdnmag/issues/05/01/CQA/, Paul DiLascia
described a method to ensure which parts of your application compiles as
managed and which as native.

Here http://msdn.microsoft.com/msdnmag/is...Optimizations/, there
is information about how to get the best perfomance when calling native code
from managed. Read the section titled 'Native and Managed Code in a Single
Image'

--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org

Nov 17 '05 #3
Thanks for the references. I had read Kang's "Power your app..." article.
The primary tip is avoiding or minimizing thunking - especially double
thunking. Given that there are no managed calls in my app and all code is
compiled under #pragma unmanaged directives, I would not expect any thunking
to occur.

Paul's article has some good tips on how to omit modules from being /clr
compiled, which I'm sure I'll use, but I'm still confused about the true
affect of #pragma unmanaged when compiled with /clr.

If all of my code is compiled under that directive and there are is
absolutely no managed code in the project, shouldn't performance be close to
native? I got an email response from a person that suggested several C++
optimizations are disabled when compiled with /clr. But the performance
difference is substantial - more than I would attribute to optimizations, or
lack thereof.

Thanks for your help. I'm not trying to be stubborn - just trying to
understand.

- Troy

----------
"Rodrigo Corral [MVP]" wrote:
Here http://msdn.microsoft.com/msdnmag/issues/05/01/CQA/, Paul DiLascia
described a method to ensure which parts of your application compiles as
managed and which as native.

Here http://msdn.microsoft.com/msdnmag/is...Optimizations/, there
is information about how to get the best perfomance when calling native code
from managed. Read the section titled 'Native and Managed Code in a Single
Image'

--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org

Nov 17 '05 #4
Sorry for the double-post. The site errored out on me and I thought it
didn't take the first one.

I sort of figured out my performance problem. I was using AtlTrace to send
frame counts to the debug output window. That was the performance killer.
It seems that when a project is compiled managed, the debug output goes
through managed objects, even for unmanaged code such as AtlTrace. (This is
just a guess, but the only conclusion I can draw.)

The good news is once that trace call was removed the performance was nearly
identical with or without the /clr switch.

Thanks, again, for your response Rodrigo.

- Troy

"Troy" wrote:
Thanks for the references. I had read Kang's "Power your app..." article.
The primary tip is avoiding or minimizing thunking - especially double
thunking. Given that there are no managed calls in my app and all code is
compiled under #pragma unmanaged directives, I would not expect any thunking
to occur.

Paul's article has some good tips on how to omit modules from being /clr
compiled, which I'm sure I'll use, but I'm still confused about the true
affect of #pragma unmanaged when compiled with /clr.

If all of my code is compiled under that directive and there are is
absolutely no managed code in the project, shouldn't performance be close to
native? I got an email response from a person that suggested several C++
optimizations are disabled when compiled with /clr. But the performance
difference is substantial - more than I would attribute to optimizations, or
lack thereof.

Thanks for your help. I'm not trying to be stubborn - just trying to
understand.

- Troy

----------
"Rodrigo Corral [MVP]" wrote:
Here http://msdn.microsoft.com/msdnmag/issues/05/01/CQA/, Paul DiLascia
described a method to ensure which parts of your application compiles as
managed and which as native.

Here http://msdn.microsoft.com/msdnmag/is...Optimizations/, there
is information about how to get the best perfomance when calling native code
from managed. Read the section titled 'Native and Managed Code in a Single
Image'

--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: kaarlo | last post by:
When I write some scrap of code using .NET C++ and place it under #pragma unmanaged. It will be compiled as native code. But can any obsfuscator etc programs see the contents of that code??? Can...
6
by: Shri | last post by:
Can anybody tell me where i can find a detailed document on #pragma .... --shri
1
by: Gustavo L. Fabro | last post by:
Greetings! Going directly to the point: myclass.h: //-------------------------------------- #pragma managed //Forward declaration
11
by: ramu | last post by:
HI, Can anyone tell me about pragma? And can u give an example of how to use it?
15
by: muttaa | last post by:
Hello all, I'm a beginner in C...May i like to know the difference between a #pragma and a #define.... Also,yet i'm unclear what a pragma is all about as i can find topics on it only in...
5
by: venkat | last post by:
Hi, I have come across the a pragma definition " #pragma switch direct ". I don't know any thing about pragma's. Even i when i search through google not getting exact information. what does...
26
by: Rick | last post by:
I'm told that "#pragma once" has made it into the ISO standard for either C or C++. I can't find any reference to that anywhere. If it's true, do any of you have a reference I can use? ...
2
by: aleemakhtar1 | last post by:
wat is use of pragma directive in embedded sys ??
0
debasisdas
by: debasisdas | last post by:
PRAGMA:-Signifies that the statement is a pragma (compiler directive). Pragmas are processed at compile time, not at run time. They pass information to the compiler. A pragma is an instruction to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.