Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Eric_B_1
New Contributor I
63 Views

Intrinsic Allocation (MIC)

So i am trying to allocate an array of aligned memory on the MIC like this

#pragma offload_attribute(push, target(mic))

#include <iostream>
#include <omp.h>
#include <ipp.h>
#include <ipps.h>
#include <immintrin.h>
#include <aligned_new>

__m512 *a,*b,*c;

void setData(int size){
    int size512 = size/16+1;
    b = new __m512[size512];
    c = new __m512[size512]();

}

#pragma offload_attribute(pop)

Compiler fails at linking stage with:

 undefined reference to `operator new[](unsigned long, std::align_val_t)'

0 Kudos
7 Replies
pbkenned1
Employee
63 Views

Thanks for submitting the issue. What version of icc are you using?  What version of MPSS?  I couldn't reproduce this with my own driver.  Can you provide one that reproduces the linking failure?

[U536991]$ icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.1.133 Build 20141023
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

[U536991]$ cat U536991.cpp
#pragma offload_attribute(push, target(mic))

#include <iostream>
#include <omp.h>
#include <ipp.h>
#include <ipps.h>
#include <immintrin.h>
#include <aligned_new>

__m512 *a,*b,*c;

void setData(int size){
    int size512 = size/16+1;
    b = new __m512[size512];
    c = new __m512[size512]();

}

#pragma offload_attribute(pop)

using namespace std;

int main()
{
   int size = 64;
   setData(size);
   cout << "\n all ok..." << endl;
   return 0;
}
[U536991]$ icc U536991.cpp -o U536991.x
[U536991]$ ./U536991.x

 all ok...
[U536991]$

 

Eric_B_1
New Contributor I
63 Views

Thanks for the post i am on:

Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.0.090 Build 20140723

MPSS version 3.4

I am trying to use a two step compile like this

icpc -c -fopenmp -w1 -Wall -Wcheck  -o main.o

icpc -fopenmp -Wl -o Mic_IPP_Final main.o

I that helps the second part it the part that fails. But basically create object file then link in and make executable.

pbkenned1
Employee
63 Views

Thanks for the reply.  icc 15.0.0.090 + MPSS 3.4 should work fine with the code snippet you posted.  The issue has nothing to do with separate compile & link steps.  If you combine compile/link in one step (as I showed in my example), then no .o file will be produced, and only the executable file will be produced.  But it's fine to have separate steps, as the icc/icpc drivers recognize .o files and call the linker to combine them and produce a finished binary.

 

[U536991]$ icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.0.090 Build 20140723
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

[U536991]$ icc -c U536991.cpp
[U536991]$ icc U536991.o -o U536991.x
[U536991]$ ./U536991.x

 all ok...
[U536991]$

 

Can you please use my main() driver, along with the code snippet you posted, and see if it links and runs on your system?  If it does, then you will need to post a more complete example that reproduces the linking failure.

 

Patrick

Eric_B_1
New Contributor I
63 Views

So I think that i isolated the issue: I have iostream, omp and std above the push pragma See below (does not compile)
#include <iostream>
#include <omp.h>

using namespace std;

#pragma offload_attribute(push, target(mic))

#include <iostream>
#include <omp.h>
#include <immintrin.h>
#include <aligned_new>

__m512 *a,*b,*c;

void setData(int size){
    int size512 = size/16+1;
    b = new __m512[size512];
    c = new __m512[size512]();

}

#pragma offload_attribute(pop)

int main()
{
   int size = 64;
   setData(size);
   cout << "\n all ok..." << endl;
   return 0;
}

FIX: Like This Have nothing above the push and boom goes the dynamite

#pragma offload_attribute(push, target(mic))

#include <iostream>
#include <omp.h>
#include <immintrin.h>
#include <aligned_new>

__m512 *a,*b,*c;

void setData(int size){
    int size512 = size/16+1;
    b = new __m512[size512];
    c = new __m512[size512]();

}

#pragma offload_attribute(pop)

#include <iostream>
#include <omp.h>

using namespace std;

int main()
{
   int size = 64;
   setData(size);
   cout << "\n all ok..." << endl;
   return 0;
}

 all ok...

I am not sure if i understand why it is that way but it is. Placing #include <iostream> above is what seams to trigger the error which is easy to work around but seams like it should not be that way. I am curious for a response on this one.

Thanks in advance

 

pbkenned1
Employee
63 Views

>>>So I think that i isolated the issue: I have iostream, omp and std above the push pragma

It looks like a bug regarding '#pragma offload_attribute(push, target(mic))'

I don't think it should make any difference whether...

#include <iostream>
#include <omp.h>

...appear before #pragma offload_attribute(push, target(mic)) or after #pragma offload_attribute(pop). 

You had duplicates of those includes inside the push, and at first I thought that might be what triggers the comp fail, but I tried removing those instances and the same comp fail occurred:

#include <iostream>
#include <omp.h>

using namespace std;

#pragma offload_attribute(push, target(mic))

#include <immintrin.h>
#include <aligned_new>

The comp fail I see on my system suggests functions declared in aligned_new didn't get the MIC attribute:

[U536991]$ icc U536991-20141211.cpp
/tmp/iccSm3UPy.o: In function `setData(int)':
U536991-20141211.cpp:(.text+0xc6): undefined reference to `std::bad_alloc::bad_alloc()'
/tmp/iccSm3UPy.o: In function `operator new(unsigned long, std::align_val_t)':
U536991-20141211.cpp:(.text._ZnwmSt11align_val_t[_ZnwmSt11align_val_t]+0x31): undefined reference to `std::bad_alloc::bad_alloc()'
/tmp/iccSm3UPy.o: In function `operator new[](unsigned long, std::align_val_t)':
U536991-20141211.cpp:(.text._ZnamSt11align_val_t[_ZnamSt11align_val_t]+0x31): undefined reference to `std::bad_alloc::bad_alloc()

 

Do you get the same comp fail?  Let me know, meantime I'll discuss this with the developers.

Patrick

 

Eric_B_1
New Contributor I
63 Views

Yes that is the error

pbkenned1
Employee
63 Views

Thanks for confirming the error.  The problem has been reported to the developers (tracking ID DPD200364387).  I'll keep this thread updated with any news.

Patrick

Reply