_mm_malloc problems with large array size (>2Gb)

_mm_malloc problems with large array size (>2Gb)


I need _mm_malloc() to allocate large arrays (>2Gb). However,
I seem to have problems. I have attached a simple program in
which I declare a size_t array dimension of 4E9 elements. I can
malloc() without problem, but _mm_malloc() segfaults on
execution. Here is the program:

int main(int argn, char** args) {
float *a;
size_t k = 4000000000;
long long i;

a = malloc(k);
for( i=0; i

a = (void *) _mm_malloc( k, 16 );
for( i=0; i


Interestingly, the compiler warns me when I try to _mm_malloc().
It seems that my size_t is being truncated to 32-bit int(???).

remark #1682: implicit conversion of a 64-bit integral type to a smaller integral type (potential portability problem)
a = (void *) _mm_malloc( k, 16 );



  • Machine: 64-bit Opteron, 8Gb memory
  • Compiler: icc 9.0

Thanks in advance,
Morgan Brown

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If you are running the 64-bit compiler, you needn't be using _mm_malloc(). glibc malloc() will give 16-byte alignment by default (at least when used with correct headers and paths). _mm_malloc() has always posed portability problems; I don't know why they aren't addressed, at least for Intel compilers. You could post an issue on premier.intel.com, after correcting your sample, if you think an improvement would help you.

Thanks, Tim. That's all I needed to know to recommend ditching _mm_malloc().


Leave a Comment

Please sign in to add a comment. Not a member? Join today