PDA

View Full Version : Easy Processor specific optimizing


edgar
9th February 2002, 20:34
>Hi,
>this is a demo project, to demonstrate my delaydll library ( using Microsofts delayed dll loader ).
>Below the text file which belong to the DelayDll.lib
>
>for easy optimizing the www.codeplay.com compiler control plugin for developper studio, makes live a lot easier.
>You can per file tell which compiler to use, M$, intel or VectorC ( or any other ) compiler.
>
>Edgar
>
>///////////////////////////////////////////
>// DelayDll easy DLL optimizing Library
>////////////////////////////////////////
>
>WHY:
>--------------------------------------------------------------------
>This is a easy to use library which let you use different compilers,
>to optimize-compile your dll for different processors.
>Move all the to be optimized classes and functions to a dll, and the DelayLoader library will automatically
>import all the functions from the fastest (for this processor available) dll.
>
>HOW:
>--------------------------------------------------------------------
>Add the DelayDll project to your workspace.
>Set a dependency for your project to this project,the library will automatically be linked against your exe.
>
>or
>Add the precompiled library delaydll.lib to your dll's configuration.
>
>
>Add a new file to your project, so you can easy change / add new dll's
>See below.
>
>Make a copy of the configuration :
>Build->Configuration.
>Select the DLL-project you want to optimize,
>You could only add a copy of win32 Release, and call it w32 Athlon Rls
>Or also make a copy of the win32 Debug, and call it w32 Athlon Dbg.
>
>The only thing you have to change in the project settings, is on the link tab, the Output name, to MainDLL.Athlon.dll for example
>
>And of course you should select another compiler, for this configuration ( using the Codeplay Compiler Controller Plug-in ).
>Or make some assembler files yourself and use them for this configuration.
>For now only compile the .c files using VectorC, so not the complete project. ( no cpp support Yet ).
>Of course you can also use the intel compiler to create optimized dlls.
>
>Example of file to be added to your project, which will make use of the optimized dlls.
><START OF FILE : MyDelayDlls.cpp>
> /******************************************************************/
> /* Sample .cpp file, to include in your executable */
> /******************************************************************/
> #include "..\DelayDll\DelayDll.h"
>
> // Tell delay loader to call my hook function
> SET_DLIHOOK_PROC
>
> /*****************************************/
> /* Which DLL's should be Delay loaded */
> /***************************************/
> // Use Upper and Lower case letters, exactly the same as in de DLL Project ,Thanks to MS DelayLoader :-(
> #pragma comment(linker, "/DelayLoad:Test.dll")
> #pragma comment(linker, "/DelayLoad:MainDLL.dll")
>
> // Descriptor for Test.dll
> // value nr, Description
> // 1 InUse, allways 1, for the last in line, use 0, so library knowns array is ended
> // 2 DllName, use this if your optimized DLL has a complete different name then you original DLL
> // 3 DllExtension, if you use an extension, Original:Test.dll, Optimized:Test.Pentium.dll
> // 4 Optimized for Processor, A PIV dll, will not be loaded on a PIII
> // 5 Used Compiler, not used, but maybe we ever want to know this??
> DLLDescriptor TestDLL[] =
> {
> 1, NULL, "Pentium.dll", DELAYDLL_PROC_PENTIUM, DELAYDLL_COMP_INTEL,
> NULL
> };
>
> // Descriptor for another DLL
> DLLDescriptor MainDLL[] =
> {
> 1, "MainPIV.dll", NULL, DELAYDLL_PROC_PIV, DELAYDLL_COMP_VECTORC,
> 1, NULL, "Athlon.dll", DELAYDLL_PROC_ATHLON, DELAYDLL_COMP_VECTORC,
> 1, NULL, "PII.dll", DELAYDLL_PROC_PII, DELAYDLL_COMP_VECTORC,
> NULL
> };
>
>
> // Only these DelayLoaded DLL will be checked for there Optimized versions
> // value nr, Description
> // 1 Dll name, (case sensitive)
> // 2 Use this Descriptor struct
> ( All DLLs, could have the same Descriptor struct, ONLY when Extensionname is used and not a fullname )
> DLLCollection pDelayLoadedDLLs[] =
> {
> "Test.dll", TestDLL, // Tries to load first : Test.Pentium.dll, then Test.dll
> "Test2.dll", TestDLL, // Tries to load first : Test2.Pentium.dll, then Test2.dll
> "MainDLL.dll", MainDLL, // Tries to load first : MainPIV.dll, then MainDLL.Athlon.dll, then MainDLL.PII.dll, then MainDLL.dll
> NULL
> };
><END OF FILE>

sample project added to this message Demodelay.zip,
also available at http://www.hss.to/Demodelay.zip