• 0

CPU Specific Optimizing Program/Plug-In


Question

I have been posting about CPUs and Intel and AMD and more, and in the end I put the blame on the programmers who do not use code optimized for XXXXX CPUs.

I have a program that is quite CPU intensive (Startup2Service) and for the upcoming Beta I am planning on releasing a SSE2 (and SSE3?) version along with the default one. I will not be one of the developers that are the reason why CPUs are not taken advantage of.

So, two questions:

a) Does VS .NET 2k5 support CPU-Specific optimizations in compiling?

a2) If not, which 3rd party app can optimize my .NET code for me?

b) Is there an app that can decompile another application to hex, then optimize it from there? I made an app and my HD crashed. The app was pretty much final, and not too big of a fanbase, so I did not attempt to recreate the source code for it, but I would like to make an SSE Optimized version of it.

TIA!

Recommended Posts

  • 0

VS2005 only supports code optimization for x64 and x86.

Found this in the docs for Visual C++ compiler.

  Quote
These options tell the compiler to optimize code generation for the specified processor.

/G5 optimizes code for the Intel Pentium processor. It sets the value of the _M_IX86 preprocessor macro to 500.

/G6 optimizes code for the Intel Pentium Pro, Pentium II, Pentium III, and Pentium 4 processors. It sets the value of the _M_IX86 preprocessor macro to 600.

/G7 optimizes code for the Intel Pentium 4 or AMD Athlon. It sets the value of the _M_IX86 preprocessor macro to 700. Code compiled with /G7 may result in these applications running slightly slower on older processors in the Pentium family (for example, Pentium III).

/GB, which is the default option, is equivalent to /G6 for Visual C++ .NET; it sets the value of _M_IX86 to 600.

/G3 and /G4 optimized for 80386 and 80486 processors. The compiler accepts these options for compatibility reasons, but they have no effect.

  • 0

OK, G7 sounds interesting. anyone know if that is SSE2? (it sounds like MSDN is trying to say SSE2 without confusing non-hardware techied programmmers)

but i guess then I want a 3rd party app... so that i can specify maybe SSE3 for the guys with the newer systems..

  • 0

No, /G7 is not SSE2.

Each generation of the Pentium processor has a different instruction pipeline length, different branch-prediction logic, etc. The optimizer often reorders instructions or pads the code with nops to help the processor out. These optimizations are not "processor specific" (like SSE2 is), but, like the documentation says, they might make the code run slower on a different processor.

  • 0

So you know that CPU specific compliles make your program faster, and other devolpers are stupid for not using them, and your writings your program in .net? Mabie you should find another language with a larger overhead :laugh:

Why instead dont you optomise your loops by coding them in assembly? Youll end up with a faster product.

Edited by lostspyder
  • 0

In the second post, he was talking about vc++ (not .net) optimizations.

And...like i told you, .net compiled files contains only MSIL.. it doesn't know anything about intel processors.it's virtual machine that converts msil instructions to machine code that the processor can understand.

  • 0

^^^^ are you sure? .Net applications obviously can take advantage of some optimizations, as displayed in teh second post in this thread.

@Lostspyder: I agree, but .NET 2.0 is a lot less hoggy than 1.x

however, you mentioned loops: my issue is not with the program not running fast enough, it runs quite fast. however, there is a lot of stuff that deal with the windows underlying code and APIs, and that is where it gets CPU_intensive

  • 0
  Debugger said:
In the second post, he was talking about vc++ (not .net) optimizations.

And...like i told you, .net compiled files contains only MSIL.. it doesn't know anything about intel processors.it's virtual machine that converts msil instructions to machine code that the processor can understand.

586741829[/snapback]

Well, I'm not 100% sure what you're talking about. .NET or C++?

If .NET: How about NGENing your assembly after install? The 2.0 NGEN is pretty good.

  • 0

^ yeah, .net 2.0 and 1.1

anyway, I never tried NGEN 2, I will give it a shot. thanks guys..

So basically, MS created a language that could not take advantege of CPU optimizations? doesn't java have a way to take advantage of cpu?

  • 0
  Computer Guru said:
^ yeah, .net 2.0 and 1.1

anyway, I never tried NGEN 2, I will give it a shot. thanks guys..

So basically, MS created a language that could not take advantege of CPU optimizations? doesn't java have a way to take advantage of cpu?

586744506[/snapback]

I'm pretty sure that the assembly is automatically optimized when it's compiled by the JIT Compiler (Which is why apps can take so long to start), or beforehand by the NGEN utility.

You have to remember that one of the points of having MSIL at all is so that it is platform independant.

  • 0

"Platform independant" pretty much translates to a Windows 2000 or XP or 2k3 machine :p

AFAIK There is no initiative for Mac, and the Linux initiative still have not completed the framework for 1.0

yeah, that is what i was thinking, if it runs on a virtual machine (such as MSIL VM) then there should be different versions of the MS Virtual Machine (its NOT msil, which simply the language) for different processors, and that would automatically improve performance for ALL .net apps

  • 0

You can use cpu specific things in .net languages by putting unsafe blocks and using imported libraries that contain assembler code.

http://www.codeguru.com/Cpp/Cpp/cpp_mfc/tu...e.php/c9411__1/

Of course the libraries that contain assembler blocks are to be written in c++.

No there is no direct way for clr languages to take care of things like SSE/SSE2 due to the compiler doing nothing but turning the code into bytecodes similiar to java.

Try taking a look at your application with the ildasm disassembler, you'll find a lot of names of methods and things that wouldn't be visible in a real compiled binary. (unless you used dotfustation).

I would imagine on the other hand that MS would have made the CLR JIT compiler take advantage of some cpu specific operations; it probably should anyways.

  Quote
AFAIK There is no initiative for Mac, and the Linux initiative still have not completed the framework for 1.0

Mono actually works sort of, try it out, its fun. Its for the Mac too. It rendered my apps really whackity. But now that .net 2.0 is out mono probably has a lot of catchup to play :)

  • 0
  Computer Guru said:
yeah i have mono, but it isnot good for apps that are 2000+ lines long.. after that it wont even run.

i use ILDASM disassemble, but just for curiosity. is there an actual usage for it?

586745185[/snapback]

I mentioned ildasm to illustrate the fact that the code isn't actually compiled. Its only transformed from the .net language to bytecodes that the JIT compiler will compile as the methods are used.

In managed code nothing is compiled until it is actually used. Java works the same way as .net in this fashion. Both have to run with a virtual machine to interpret the bytecodes to run on the platform in question.

Yeah I haven't had good luck with Mono either...

[EDIT]

Yeah when I said the code was tranformed to bytecodes I ment that its transformed to MSIL (microsoft intermediate language) which how .net applications work. Every language turns out the same when compiled.

Except that VB.NET will always init any variables while c# might not. Not sure about how c++ or J# or other languages with msil. I don't write managed c++ often.

Edited by NEOBassDUDE
  • 0

^ me neither.

I realize how .NET works, but I was wondering if in the .NET structure somewhere there was not some kind of already built-in CPU Optimization.... I'll have to ask MS... Best chat with my MSDN contact. If I find anything out, I'll be sure to let you all know.

  • 0

I don't think you should be using any SIMD extensions in your code if you don't understand what they are for. Depending on what kind of code you'r writing, using SIMD will either increase speed, or in some cases, slow down, your program, because most programmers don't understand what SIMD extensions like: MMX, 3DNow and SSE extension sets do. Learn x86 assembly well, before you decide that you want to use cpu specific instructions.

You are not going to see any noticable performance increase unless you learn to use the insintrics that the compiler supports, which are very raw wrappers around the assembly version of the instructions.

  • 0
  Computer Guru said:
So I cannot just tell a compiler to sompile my .net app with SIMD (if it were even possible)?

586750431[/snapback]

No.

.NET was never designed to work like that. It performs the proper optimizations at runtime automatically.

MSIL - Microsoft Intermediate Language. Intermediate being the keyword.

Remember. There are actually two compilers your code goes through before running.

You compile it into an EXE, which contains a ton of MSIL, Metadata, etc.

Then, that MSIL code is compiled into native code at runtime. Here is where any CPU-dependant optimizations occur. The code generated is dependant on the system executing the .NET assembly.

Then, the CLR executes that native code.

It's a wonderfully complex process, but It works.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Chinese? It sounds extremely dangerous. I’ll reconsider buying a Meta Quest 3.
    • - What's your salary? Is it more than $100k a year? - Nah, it's $100 mil a year.
    • Compared to my ear buds which are the size of a matchbox, cover a much broader frequency range, and work everywhere without setup? Yeah, still not buying this as a replacement.
    • Meta's Superintelligence team staffed by 50% Chinese talent, 40% ex-OpenAI by Hamid Ganji Mark Zuckerberg's latest big bet at Meta involves building a team of the best AI superstars in the market to lead the so-called Superintelligence Labs. The goal of this team is to develop AI models that will ultimately lead to Artificial General Intelligence (AGI). AGI refers to an AI model with capabilities comparable to, or even beyond, those of the human brain. Achieving human-level cognitive abilities with an AI model requires substantial investments, as well as hiring the best talent to build such a system. That's why Meta is throwing hundreds of millions of dollars at AI researchers from OpenAI, Apple, and other companies to recruit them for its Superintelligence team. A user on X has now shared a spreadsheet that provides us with some unique insights into Meta's Superintelligence team and the origins of its 44 employees. The leaker claims this information comes from an anonymous Meta employee. The listing claims that 50 percent of the staff at the Superintelligence team are from China, which demonstrates the significant role of Chinese or Chinese-origin researchers in Met's AI efforts. Additionally, 75 percent of these staff hold PhDs, and 70 percent of them work as researchers. Interestingly, 40 percent of the staff are ex-OpenAI employees whom Mark Zuckerberg poached from the maker of ChatGPT. Additionally, 20 percent of Meta's Superintelligence team members come from Google DeepMind, and another 15 percent come from Scale AI, a startup that Meta recently acquired in a $15 billion deal. Another interesting point is that 75 percent of the Superintelligence team are first-generation immigrants. The leaker claims that each of these employees is now earning between $10 million and $100 million per year, although Meta still needs to confirm these substantial figures. However, it has already been reported that Meta is offering up to $100 million in signup bonuses to poach the best AI talent from OpenAI and other rivals. The revelation that half of Meta's Superintelligence team consists of Chinese nationals could trigger concerns within the Trump administration and Congress.
    • From a quick Google it seems 6GHz is optional on 802.11be. Ubiquiti has one, Unifi U7 Lite.
  • Recent Achievements

    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
    • One Month Later
      Ian_ earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      ATLien_0
      207
    3. 3
      Michael Scrip
      206
    4. 4
      Xenon
      138
    5. 5
      +FloatingFatMan
      113
  • Tell a friend

    Love Neowin? Tell a friend!