Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Tips for Porting software to a 64-bit platform

SergeyKostrov
Valued Contributor II
10,840 Views

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 Kudos
61 Replies
SergeyKostrov
Valued Contributor II
3,258 Views
This is a test post with embedded jpg-format image. . C:\intel_logo.jpg
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
>>...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.
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
This is a test post - investigation of performance issues on the new IDZ website ( done from a dual-core computer ).
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
>>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.
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
Here is a screenshot of the Windows Resource Monitor for cases 4GB, 8GB, 16GB, 32GB and 64GB: memtestapp64.jpg
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
>>...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.
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views

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 ).

0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
Here is a screenshot of the Windows Resource Monitor for cases 16GB, 32GB, 64GB, 128GB, 160GB and 192GB: memtestapp64.jpg
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
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
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
22. Take into account that all editions of Visual Studio Express ( 2008, 2010, 2012, etc ) don't support development for 64-bit platforms.
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
>>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
0 Kudos
Bernard
Valued Contributor I
3,258 Views
>>>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.
0 Kudos
Bernard
Valued Contributor I
3,258 Views
I would like to add that Microsoft did a good job of integrating and combining driver development with Visual Studio IDE environment.
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
>>...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).
0 Kudos
Bernard
Valued Contributor I
3,258 Views
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?
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
>>@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.
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
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'.
0 Kudos
SergeyKostrov
Valued Contributor II
3,258 Views
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.
0 Kudos
Bernard
Valued Contributor I
3,258 Views
>>>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?
0 Kudos
Bernard
Valued Contributor I
3,275 Views
>>>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
0 Kudos
SergeyKostrov
Valued Contributor II
3,275 Views
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.
0 Kudos
Reply