5. Who am I
-> Fernando Moreira ( @fpmore )
-> MSc student @ FEUP
6. Who am I
-> Fernando Moreira ( @fpmore )
-> MSc student @ FEUP
-> Undergraduate Researcher @ Porto Interactive Center
7. Who am I
-> Fernando Moreira ( @fpmore )
-> MSc student @ FEUP
-> Undergraduate Researcher @ Porto Interactive Center
-> Microsoft Student Partner Lead @ M$ PT
8. Who am I
-> Fernando Moreira ( @fpmore )
-> MSc student @ FEUP
-> Undergraduate Researcher @ Porto Interactive Center
-> Microsoft Student Partner Lead @ M$ PT
-> I’ve doing C++ for over… 5y
13. Who are you ?
-> Norte . Centro . Sul . Açores
14. Who are you ?
-> Norte . Centro . Sul . Açores . Madeira
15. Who are you ?
-> Norte . Centro . Sul . Açores . Madeira . FMI
16. Who are you ?
-> Norte . Centro . Sul . Açores . Madeira . FMI
-> Who has experience with C?
17. Who are you ?
-> Norte . Centro . Sul . Açores . Madeira . FMI
-> Who has experience with C? And with C++?
18. Who are you ?
-> Norte . Centro . Sul . Açores . Madeira . FMI
-> Who has experience with C? And with C++?
-> Who has experience with 64bit native dev?
35. advantagesOver_x86()
-> Address space : Theoretical limit of 16 ExaBytes (2^64)
-> More available registers. (there’s one called RIP)
-> Larger instruction set with emphasis on SIMD
36. advantagesOver_x86()
-> Address space : Theoretical limit of 16 ExaBytes (2^64)
-> More available registers. (there’s one called RIP)
-> Larger instruction set with emphasis on SIMD
-> SSE1, SSE2, and SSE3 are always there
37. advantagesOver_x86()
-> Address space : Theoretical limit of 16 ExaBytes (2^64)
-> More available registers. (there’s one called RIP)
-> Larger instruction set with emphasis on SIMD
-> SSE1, SSE2, and SSE3 are always there
-> Unified function calling convention
38. advantagesOver_x86()
Can run x86 environments
Can run x86 binaries under x64 environments
On Windows: . 32bit processes can’t load 64bit DLLs for execution
. 64bit processes can’t load 32bit DLLs for execution
46. nativeDev_x64( data_model )
-> On Microsoft Win64 : LLP64 model
-> On Linux : LP64 model
-> LLP64: short( 2 ), int( 4 ), long( 4 ), ptr( 8 ), long long(8)
47. nativeDev_x64( data_model )
-> On Microsoft Win64 : LLP64 model
-> On Linux : LP64 model
-> LLP64: short( 2 ), int( 4 ), long( 4 ), ptr( 8 ), long long(8)
-> LP64: short( 2 ), int( 4 ), long( 8 ), ptr( 8 ), long long( 8 )
48. nativeDev_x64( data_model )
-> On Microsoft Win64 : LLP64 model
-> On Linux : LP64 model
-> LLP64: short( 2 ), int( 4 ), long( 4 ), ptr( 8 ), long long(8)
-> LP64: short( 2 ), int( 4 ), long( 8 ), ptr( 8 ), long long( 8 )
Can you see the data portability problem?
49. nativeDev_x64( data_model )
-> On Microsoft Win64 : LLP64 model
-> On Linux : LP64 model
-> LLP64: short( 2 ), int( 4 ), long( 4 ), ptr( 8 ), long long(8)
-> LP64: short( 2 ), int( 4 ), long( 8 ), ptr( 8 ), long long( 8 )
Suggestions: Use conditional compilation and type aliasing.
50. nativeDev_x64( data_model )
-> On Microsoft Win64 : LLP64 model
-> On Linux : LP64 model
-> LLP64: short( 2 ), int( 4 ), long( 4 ), ptr( 8 ), long long(8)
-> LP64: short( 2 ), int( 4 ), long( 8 ), ptr( 8 ), long long( 8 )
Suggestions: Use conditional compilation and type aliasing.
Make conscious usage of the sizeof operator.
52. nativeDev_x64( data_model )
-> On x86 : ptr( 4 ), size_t( 4 ), ptrdiff_t( 4 )
-> On x64 : ptr( 8 ), size_t( 8 ), ptrdiff_t( 8 )
53. nativeDev_x64( data_model )
-> On x86 : ptr( 4 ), size_t( 4 ), ptrdiff_t( 4 )
-> On x64 : ptr( 8 ), size_t( 8 ), ptrdiff_t( 8 )
These ones will increase memory usage…
But will be performance-wise.
56. nativeDev_x64( common_pitfalls )
-> Usage of magic numbers & bit-wise ops: 0x7fffffff
-> Functions with variable number of arguments : printf
57. nativeDev_x64( common_pitfalls )
-> Usage of magic numbers & bit-wise ops: 0x7fffffff
-> Functions with variable number of arguments : printf
-> Virtual functions
58. nativeDev_x64( common_pitfalls )
-> Usage of magic numbers & bit-wise ops: 0x7fffffff
-> Functions with variable number of arguments : printf
-> Virtual functions
-> Data exchange between x86 and x64 apps
59. nativeDev_x64( common_pitfalls )
-> Usage of magic numbers & bit-wise ops: 0x7fffffff
-> Functions with variable number of arguments : printf
-> Virtual functions
-> Data exchange between x86 and x64 apps
-> Data misalignment : SSE requires 16-byte alignment
63. nativeDev_x64( optimization_tips )
-> Use native types for loops or tight data usage
-> Use 16-byte alignment for SSE loads and stores
-> Heap-allocs in Win64 and XBOX360 are 16-byte aligned
64. nativeDev_x64( optimization_tips )
-> Use native types for loops or tight data usage
-> Use 16-byte alignment for SSE loads and stores
-> Heap-allocs in Win64 and XBOX360 are 16-byte aligned
-> *Use* intrinsics : #include <immintrin.h>
65. nativeDev_x64( optimization_tips )
-> Use native types for loops or tight data usage
-> Use 16-byte alignment for SSE loads and stores
-> Heap-allocs in Win64 and XBOX360 are 16-byte aligned
-> *Use* intrinsics : #include <immintrin.h>
-> Unroll loops and sort object’s member data by their size
69. nativeDev_x64( real-world_tips )
-> Don’t sacrifice your software architecture.
-> Don’t use it if you don’t know how to.
-> Don’t go into premature optimization.
70. nativeDev_x64( real-world_tips )
-> Don’t sacrifice your software architecture.
-> Don’t use it if you don’t know how to.
-> Don’t go into premature optimization.
-> Do it at lower levels and then hide it.
71. nativeDev_x64( real-world_tips )
-> Don’t sacrifice your software architecture.
-> Don’t use it if you don’t know how to.
-> Don’t go into premature optimization.
-> Do it at lower levels and then hide it.
-> Trust your compiler to help you do the job.
75. codeAnalysis_and_DebugTools()
-> Your IDE : LEARN to fu**** use it!
-> Conditional break points, call-stack
-> Free tool : CppCheck (CmdLine, Eclipse, CodeBlocks, …)
76. codeAnalysis_and_DebugTools()
-> Your IDE : LEARN to fu**** use it!
-> Conditional break points, call-stack
-> Free tool : CppCheck (CmdLine, Eclipse, CodeBlocks, …)
-> State-of-the-art tool: PVS-Studio (VS 05,08,10)
77. codeAnalysis_and_DebugTools()
-> Your IDE : LEARN to fu**** use it!
-> Conditional break points, call-stack
-> Free tool : CppCheck (CmdLine, Eclipse, CodeBlocks, …)
-> State-of-the-art tool: PVS-Studio (VS 05,08,10)
-> Do pair programming and peer-review if possible
81. costProspectionOn_x64Dev()
-> Hardware & Software (IDE + Plugins + Tools + Libs)
-> You’ll need to teach the developers (theory & practice)
-> A port takes time, adds bugs, and it’s not creative
82. costProspectionOn_x64Dev()
-> Hardware & Software (IDE + Plugins + Tools + Libs)
-> You’ll need to teach the developers (theory & practice)
-> A port takes time, adds bugs, and it’s not creative
-> … plus you’ll probably have to maintain two code paths
83. costProspectionOn_x64Dev()
-> Hardware & Software (IDE + Plugins + Tools + Libs)
-> You’ll need to teach the developers (theory & practice)
-> A port takes time, adds bugs, and it’s not creative
-> … plus you’ll probably have to maintain two code paths
-> Full implementation adds creativity, but takes much
more time and will add many more bugs.