Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

Tips for Porting software to a 64-bit platform

SergeyKostrov
高評価コントリビューター II
10,261件の閲覧回数

I'd like to share some experience on porting a C/C++ project to a 64-bit platform. It was started last week and I already
have lots of different problems.

Here is a list of Tips, Detected Problems and Issues:

1. I recommend to take a look at the following topics on MSDN if you're about to start a 64-bit programming:

"Platform SDK: 64-bit Windows Programming"
"Migration Tips"
"64-Bit Programming with Visual C++"
"How to: Configure Projects to Target Platforms"

2. Turn on a /Wp64 compiler option for Microsoft compatible C++ compilers. It detects 64-bit
portability problems on types that are marked with the __w64 keyword;

3. Issue - LONGLONG data type:
...
#if !defined( _M_IX86 )
typedef __int64 LONGLONG;
#else
typedef double LONGLONG;
#endif
...

4. Issue - Date & Time CRT-functions and data types

5. Issue - A 'size_t' type is used in 'new' C++ operators to pass a size of a memory to allocate and
it is 8-bytes long on a 64-bit platform

6. Microsoft C++ compiler ( a test case ):
...
int iInt32 = 0xffffeeeeddddcccc; // -> iInt32 = 0xddddcccc - This is simplya verification of truncation
...

7. Problem - MinGW C++ compiler ( a test case ):
...
int iInt32 = 0xffffeeeeddddcccc; // -> Error: integer constant is too large for "long" type
...

8. Use explicit 'ifdef's for different platforms ( pseudo codes ):
...
#ifdef _16BIT_PLATFORM_
//...
#endif
#ifdef _32BIT_PLATFORM_
//...
#endif
#ifdef _64BIT_PLATFORM_
//...
#endif
...

9. Default ( turn on ) the following warnigs for Microsoft compatible C++ compilers:

#pragma warning ( default : 4239 )// Nonstandard extension used : 'type cast' : conversion from 'type1' to 'type2'
#pragma warning ( default : 4242 )// Conversion from 'type1' to 'type2', possible loss of data
#pragma warning ( default : 4244 )// Conversion from 'type1' to 'type2', possible loss of data
#pragma warning ( default : 4305 )// 'Initializing' : truncation from 'type1' to 'type2'
#pragma warning ( default : 4309 )// 'Initializing' : truncation of constant value
#pragma warning ( default : 4311 )// 'Type cast' : pointer truncation from 'type1' to 'type2'

10. Verify how the __w64 keyword works for Microsoft compatible C++ compilers:

// Test Case - Verification of __w64 keyword - based on MSDN example
// 'V64C' stands for 'Verify 64-bit Compatibility'

...
#if ( defined ( _WIN32_MSC ) || defined ( _WIN32_ICC ) )
#define _RTV64C__w64
#endif
#if ( defined ( _WIN32CE_MSC ) || defined ( _WIN32_BCC ) || defined ( _WIN32_MGW ) ||\\
defined ( _COS16_TCC ) )
#define _RTV64C
#endif
...

#pragma warning ( default : 4244 )// Conversion from 'type1' to 'type2', possible loss of data

#define _WIN64
//#undef _WIN64

typedef int Int_32;

#ifdef _WIN64
typedef __int64 Int_Native;
#else
typedef int _RTV64C Int_Native;
#endif

Int_32 iInt_32 = 0xffeeddcc;
Int_Native iInt_Native = 0xffffeeeeddddcccc;
iInt_32 = iInt_Native; // MSDN - Warning C4244: 64-bit int assigned to 32-bit int
// Compiler - Warning C4244: '=' : conversion from 'Int_Native' to 'Int_32', possible loss of data
#undef _WIN64

#pragma warning ( disable : 4244 )
...

11. If a project has Test Cases ALL of them must be verified on a 64-bit platform

0 件の賞賛
61 返答(返信)
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
This is a test post with embedded jpg-format image. . C:\intel_logo.jpg
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
>>...This is a test post with embedded jpg-format image. . It didn't work if an image is located on a local drive. I expected that it would be uploaded automatically. Here is my question: How could I embedd an image in a post? Thanks in advance.
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
This is a test post - investigation of performance issues on the new IDZ website ( done from a dual-core computer ).
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
>>http://software.intel.com/en-us/forums/showpost.php?p=189214 >> >>for more technical details. >> >>Test Results: >> >>OS : Windows 7 64-bit Home Premium >>CPU: AMD ( 4 cores ) >>RAM: 6GB >>VM: 96GB initial size \ 128GB maximum size >>APP: MemTestApp64.exe \ Release configuration >> >>Attempts to allocate memory: >> >>0.25GB - Allocated >>0.50GB - Allocated >>1.GB - Allocated >>2.GB - Allocated >>4.GB - Allocated >>8.GB - Allocated >>14.GB - Allocated ( Target for a 61000x61000 Single-Precision matrix ) >>16.GB - Allocated >>28.GB - Allocated ( Target for a 61000x61000 Double-Precision matrix ) >>32.GB - Allocated >>64.GB - Allocated Just verified how MemTestApp64.exe works on a system with Windows 7 Professional and Intel CPU ( 16GB of physical memory / VM: 96GB initial size \ 128GB maximum size ): 0.25GB - Allocated 0.50GB - Allocated 1.GB - Allocated 2.GB - Allocated 4.GB - Allocated 8.GB - Allocated 14.GB - Allocated ( Target for a 61000x61000 Single-Precision matrix ) 16.GB - Allocated 28.GB - Allocated ( Target for a 61000x61000 Double-Precision matrix ) 32.GB - Allocated 64.GB - Allocated A screenshot will be provided for cases 4GB, 8GB, 16GB, 32GB and 64GB.
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
Here is a screenshot of the Windows Resource Monitor for cases 4GB, 8GB, 16GB, 32GB and 64GB: memtestapp64.jpg
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
>>...Here is a screenshot of the Windows Resource Monitor for cases 4GB, 8GB, 16GB, 32GB and 64GB... It took more than 5 attempts before the image was finally embedded.
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数

20. A version 4 of the 'MemTestApp' that could be used to test allocation of large blocks of memory is attached. I tested the application for a couple of extreme cases ( from 64GB up to 192GB ).

SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
Here is a screenshot of the Windows Resource Monitor for cases 16GB, 32GB, 64GB, 128GB, 160GB and 192GB: memtestapp64.jpg
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
21. Here are a couple of notes related to allocation of memory on the stack ( also known as automatic allocation ): - For 'float' Floating-Point data type maximum size of the matrix in case of automatic allocation on the stack is ~23170x23170 - For 'double' Floating-Point data type maximum size of the matrix in case of automatic allocation on the stack is ~16383x16383 - In cases when it exceeds the 2GB limit a C/C++ compiler or a Fortran compiler could fail to compile sources. For example, MS C++ compiler fails with an Error C1126: automatic allocation exceeds 2G - In cases when it exceeds the 2GB limit a C/C++ compiler or a Fortran compiler could fail to compile sources. For example, MS C++ compiler fails with an Error C2148: total size of array must not exceed 0x7FFFFFFF bytes 0x7FFFFFFF = 2147483647 bytes
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
22. Take into account that all editions of Visual Studio Express ( 2008, 2010, 2012, etc ) don't support development for 64-bit platforms.
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
>>22. Take into account that all editions of Visual Studio Express ( 2008, 2010, 2012, etc ) don't support development for 64-bit platforms. Correction. Visual Studio Express 2012 for WIndows 8 and for Windows Desktop allow to create applications for 64-bit platforms. Take a look at 'Supported architectures' sections at: Web-link: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-8#product-express-windows-requirements and Web-link: http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-for-windows-desktop#product-express-desktop-requirements
Bernard
高評価コントリビューター I
3,081件の閲覧回数
>>>Correction. Visual Studio Express 2012 for WIndows 8 and for Windows Desktop allow to create applications for 64-bit platforms. Take a look at 'Supported architectures' sections at:>>> Thanks for posting this.
Bernard
高評価コントリビューター I
3,081件の閲覧回数
I would like to add that Microsoft did a good job of integrating and combining driver development with Visual Studio IDE environment.
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
>>...Microsoft did a good job of integrating and combining driver development with Visual Studio IDE... Please take into account that the subject of the thread is Tips for Porting software to a 64-bit platform and it is not related to porting drivers to a 64-bit Windows platform(s).
Bernard
高評価コントリビューター I
3,081件の閲覧回数
Sergey Kostrov wrote:

>>...Microsoft did a good job of integrating and combining driver development with Visual Studio IDE...

Please take into account that the subject of the thread is Tips for Porting software to a 64-bit platform and it is not related to porting drivers to a 64-bit Windows platform(s).

Ok:) @Sergey Do you do any kind of driver development?
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
>>@Sergey >>Do you do any kind of driver development? Long time ago I've implemented two simple drivers for Windows 95 OS but, unfortunately, I'm not interested in the driver programming any longer.
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
23. Two problems with MinGW C/C++ compiler detected: [ Problem 1 ] ... __int64 iValueS = 0LL; iValueS = ( 9223372036854775807i64 ); ... Compilation error Invalid suffix 'i64' on integer constant with MinGW C/C++ compiler. Use LL instead of i64. [ Problem 2 ] Compilation error Integer constant is too large for 'long' type if assignment to a signed 64-bit variable with a max value is done without using LL suffix: ... __int64 iValueS = ( 9223372036854775807 ); ... MinGW C/C++ compiler casts to a type 'long' instead of to a type 'long long'.
SergeyKostrov
高評価コントリビューター II
3,081件の閲覧回数
24. A problem with Borland C/C++ compiler detected: [ Problem ] Take into account that Borland C++ compiler, for example version 5.x, doesn't support suffixes LL and ULL.
Bernard
高評価コントリビューター I
3,081件の閲覧回数
>>>Two problems with MinGW C/C++ compiler detected:>>> Have you tested with MinGW compiler usage of suffixes such like a UL and LL in macro definition?
Bernard
高評価コントリビューター I
3,098件の閲覧回数
>>>Long time ago I've implemented two simple drivers for Windows 95 OS but, unfortunately, I'm not interested in the driver programming any longer.>>> I thought that you could have been able to help me with my project.So far nobody was able to help me. here is link:http://software.intel.com/en-us/forums/topic/351986
SergeyKostrov
高評価コントリビューター II
3,098件の閲覧回数
25. Floating Point Unit precision control on a 64-bit platform: Take into account that on 64-bit platforms changing the floating-point precision is not supported. If the precision control mask _MCW_PC is used on a 64-bit platform a Debug Assertion Failed message will be displayed. When, for example, a _control87 CRT-function is called in an application ( Debug configuration only! ) the following expression is verified: ...( mask &~ ( _MCW_DN | _MCW_EM | _MCW_RC ) ) == 0... and it checks if there is an attempt to change precision, or in another words there is attempt to set _MCW_PC bits. In a Release configuration there are No any errors or warning messages.
返信