bafc63eaf8f3cadcedabb685da5d72b7.ppt
- Количество слайдов: 44
DEV 332. NET Framework: 64 -Bit Development Today And Tomorrow Kang Su Gatlin Visual C++ Program Manager Microsoft Corporation Geralyn Miller. NET Solutions Architect Microsoft Corporation
Agenda A bit of motivation. . . and a state of play Today: 64 -bit Native C++ State of Tools, Porting Code, Problem areas, Performance Future: 64 -bit. NET Framework and versus 2005 State of Tools, Porting Code, COM Interop, Language Specifics
Why 64 -Bit Architecture? Larger Address Space Win 64 Total Virtual Address Space 16 TB Virtual Address Space per 64 bit Process 8 TB Virtual Address Space per 32 bit Process 4 GB if compiled with /LARGEADDRESSAWARE 2 GB otherwise Windows XP Professional 32 GB / 1 -2 cpus Windows Server 2003 Standard 32 GB / 1 -4 cpus Windows Server 2003 Enterprise 1 TB / 1 -8 cpus Windows Server 2003 Data. Center 1 TB / 1 -64 cpus Larger values supported by primitive types 2^64 >> 2 ^32 18, 446, 744, 073, 709, 551, 616 >> 4, 294, 967, 296 Performance? Possibly, but code size will increase
Where Are The Application Spaces? … with data? … with high performance computing workloads? … with 32 -bit primitive types? These are all problem spaces where 64 bit solutions can make sense
State Of Play Two mainstream 64 bit architectures supported by Windows Itanium Processor Family x 64 – a. k. a. AMD 64, EM 64 T Windows versions available (Itanium) and in beta (x 64) today
State Of Play: Itanium “in-order” processor VLIW Bundling and templates Support for predication Support for control/data speculation Rotating register support for SWP Branch prediction Functional Units galore LOTS of registers 128 floating point 128 integer + predicate, branch, control registers… whew! Tough on assembly folks No addressing modes
State Of Play: x 64 Stretch x 86 architecture Runs legacy x 86 at machine speeds Increased register width of x 86 registers to 64 -bit 8 additional general purpose registers REX instruction prefix addresses the new registers 8 additional 128 bit XMM registers VC++ does not generate x 87 nor MMX code
“OK, How Do I Get Started With 64 -bit Development? ” Do you remember Win 16 to Win 32? 32 to 64 -bit much easier The memory model has stayed the same sizeof_x 86(long) == sizeof_amd 64(long) Win 64 is simply Windows Essentially simple pointer stretch of Win 32 API
Agenda A bit of motivation. . . and a state of play Today: 64 -bit Native C++ State of Tools, Porting Code, Problem areas, Performance Future: 64 -bit. NET Framework and versus 2005 State of Tools, Porting Code, COM Interop, Language Specifics
Wo. W… It Works! Windows on Windows 64 (WOW 64) Isolates 32 -bit Applications Notably file and registry isolation Console GUI Services Separate DLLs Performance hit? Substantial on Itanium Little to none on x 64
Wow 64 Process Layout NT Executive Win 32 k. sys Kernel Mode User Mode Reserved Address Space 0 x 0000`7 FFEFFFF or 0 x 0000`FFFEFFFF 64 -bit ntdll. dll Wow 64 win. dll Wow 64 cpu. dll 32 -bit ntdll. dll 32 -bit modules
Current Development Model x 86 -based Computer (or using Wo. W) § Develop and test 32 bit code here § Cross compile for 64 -bit § Send executable to 64 -bit computer 64 -bit Computer § Execute code here § Debug remaining bugs here
State Of The 64 bit VC Dev Tools World Tools Itanium AMD 64/EM 64 T Current Supported Toolset (uses 6. 0 version of libs) PSDK toolset Less conformant FE Cross compiler Only unmanaged codegen Win. Dbg and VS minidebugger PSDK toolset (available only through Betaplace) VS 2005 based Cross compiler Only unmanaged codegen Win. Dbg debugging 7. 1 Libs compiler version New complier for 7. 1 libs Only unmanaged codegen libs 7164@microsoft. com Whidbey Beta 1 Both 64 bit hosted and cross compilers, VS can install on Win 64, managed codegen support, VS 2005 libs for all platforms. Remote debugging.
Porting Your App To 64 -bit Use compiler switch (-Wp 64) 64 -bit brings differences – LLP 64 T *, size_t: 64 bit int, long: built-in integers are ALL 32 bit long: 64 bit always Alignment changes Misalignment can be fatal on Itanium 32 and 64 bit code can NOT be in same process API Data Model int Win 32 ILP 32 32 Win 64 LLP 64 32 32 64 UNIXes LP 64 32 64 64 long pointer
Porting Issues From 32 To 64 bit
Profile Guided Optimization? Compiler can’t answer everything… if(a < b) foo(); else baz(); How often is a < b? for(i = 0; i < count; ++i) bar(); What is the typical value of count?
Profile Guided Optimization Source Compile with /GL Object files Link with /LTCG: PGI Instrumented Image Scenarios Instrumented Image Output Profile data Link with /LTCG: PGO Object files Optimized Image
How Much Performance Does PGO Buy You? Performance increase is architecture and application specific Itanium tends to benefit the most Large applications tend to benefit more than small If you understand your real-world scenarios then PGO is almost always a win
PGO Improvement Over LTCG
Agenda A bit of motivation. . . and a state of play Today: 64 -bit Native C++ State of Tools, Porting Code, Problem areas, Performance Future: 64 -bit. NET Framework and versus 2005 State of Tools, Porting Code, COM Interop, Language Specifics
Developer Roadmap Visual Studio 2005 Visual Studio. NET 2003 • “Everett Release” • Windows Server 2003 integration • Support for. NET Compact Framework and device development • Improved performance Visual Studio “Orcas” • “Whidbey” release • Windows “Longhorn” integration • SQL Server 2005 integration • New UI tools and designers • 64 bit Framework • Extensive managed interfaces (Win. FX) • Improved IDE productivity and community support • Extended support for XML Web services • Office programmability
Availability Of 64 -bit. NET Framework Visual Studio 2005 timeframe Servers and workstations X 64 and IA 64 support OS Dependency >= Windows Server 2003 SP 1 No Windows 2000 Server 64 bit Edition Future Windows 64 bit client releases Longhorn, Windows XP
64 -bit. NET Framework And Tools Support Parity w/ 32 -bit product Common Language Runtime. NET Framework Class Libraries (including ASP. NET, Windows Forms, ADO. NET) SDK Tools Visual Studio. NET supported on WOW 64 New JIT, GC, exception handling, and debugging services
Moving 32 -bit. NET Framework applications To 64 -bit
Managed Code on 64 Bit Verifiable code just runs 32 bit Whidbey runs on Wo. W 64 bit Whidbey runs native Assemblies marked for ‘bitness‘ (32 bit, 64 bit, neutral) COM Interop, P/Invoke, Floating Point may require changes Images containing native code treated as native (Managed C++) Nearly all cost is in test runs “The last automated test pass we did on 64 bit before the holidays produced results similar to those on 32 bit after one bug in a cross domain was fixed for us. Oh the joy of being fully managed! “ – Rok Yu, Jscript
Porting Cost To 64 bit
Writing Portable Managed Code Verifiable No native code (IL only) No pointer arithmetic Follow Interop Rules Know Architecture Differences Beware Floating Point
Interop Rules Signatures Dll. Import, Declare ‘int’ and System. Int. Ptr API’s must exist on all platforms Marshaling Struct. Layout. Attribute Marshal. Size. Of
‘Int’ And System. Int. Ptr Int and Int. Ptr in import signatures ‘int’ is System. Int 32, 32 bit size System. Int. Ptr is size of platform integer and pointer, may be 32 or 64, or ?
‘Int’ And System. Int. Ptr [Struct. Layout(Layout. Kind. Sequential)] internal class SECURITY_ATTRIBUTES { internal int n. Length = 0; internal int lp. Security. Descriptor = 0; internal int b. Inherit. Handle = 0; }
‘Int’ And System. Int. Ptr [Struct. Layout(Layout. Kind. Sequential)] internal class SECURITY_ATTRIBUTES { internal int n. Length = 0; internal Int. Ptr lp. Security. Descriptor = Int. Ptr. Zero; internal int b. Inherit. Handle = 0; }
Struct. Layout. Attribute Layout. Kind. Explicit Determines Managed Layout Use correct Field. Offset Use with ‘fixed’ in C# Layout. Kind. Sequential Determines Managed, Unmanaged Layout Use correct Packing. Size Default for VB, C#
Correct Marshaling Use Marshal. Size. Of Struct Marshaling Size Platform Pointer Size Examples: internal class OSVERSIONINFO { public OSVERSIONINFO() { OSVersion. Info. Size = (int)Marshal. Size. Of(this); } Marshal. Size. Of(typeof(System. Int. Ptr))
Using COM Components COM is native Neutral apps may use platform specific COM components No COM interop between architectures Component may not exist on 64 bit May elect to run in Wo. W only
Exposing To COM No interop between architectures 32 bit apps only exposed to 32 bit May expose neutral apps on each architecture Must register for each architecture Type Libraries are not neutral
Language Specifics Visual Basic. NET C# Managed Extensions to C++
Visual Basic Creates platform-neutral IL Safe, verifiable Can ‘break’ portability Explicit or Sequential Layout Using ‘Declare’ or ‘Dll. Import’
C# Creates platform-neutral IL Mostly Safe, Verifiable ‘Unsafe’ allows pointer arithmetic Can ‘break’ portability Explicit or Sequential Layout Using ‘Dll. Import’
Managed C++ 7. 0 Never verifiable Contains native code ‘IJW’ – doesn’t use Dll. Import Uses native headers and libraries 32 -bit images 7. 1 Use ‘cookbook’ May create verifiable images May be IL only Still may use “IJW” Whidbey Create fully verifiable images Greatly improved IJW
Closing Summary int and long are 32 -bits Pointers are 64 -bits Don’t assume data sizes Align data on natural boundaries Native Profile guided optimization can greatly help performance on IA/64 Managed Verifiable code just runs The new power of the platform enables us to do even more!
Resources 64 -bit Windows Programming “Getting ready for 64 -bit Windows” The New Data Types “Designing 64 -bit interfaces” “Running 32 -bit applications” (wow 64 registry redirection, debugging, performance, app installation) “Migration Tips” (common compiler errors) “Introduction to Developing Applications for the 64 bit Version of Windows” “Windows Data Alignment on IPF, x 86, and x 86 -64” “Application Compatibility Guide”
Attend a free chat or web cast http: //www. microsoft. com/communities/chats/default. mspx http: //www. microsoft. com/usa/webcasts/default. asp List of newsgroups http: //communities 2. microsoft. com/communities/newsgroups/en-us/default. aspx MS Community Sites http: //www. microsoft. com/communities/default. mspx Locate Local User Groups http: //www. microsoft. com/communities/usergroups/default. mspx Community sites http: //www. microsoft. com/communities/related/default. mspx
Please fill out a session evaluation on Comm. Net Q 1: Overall satisfaction with the session Q 2: Usefulness of the information Q 3: Presenter’s knowledge of the subject Q 4: Presenter’s presentation skills Q 5: Effectiveness of the presentation
© 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
bafc63eaf8f3cadcedabb685da5d72b7.ppt