malloc issue on more than one MIC

malloc issue on more than one MIC

I have a source code:

 

#include<offload.h>
#include<stdio.h>


int main() {
    int ndev = _Offload_number_of_devices();
    printf("Ndev = %d\n", ndev);
    void *u;
    for (int d = 0; d < ndev; d++) {
#pragma offload target(mic: d) nocopy(u)
        {
            u = malloc(1); // 1 is just for demo, it's actually nz*ny*nx in my application
            printf("u on %d is %x\n", d, u);
            fflush(0);
        }
    }


    for (int d = 0; d < ndev; d++) {
#pragma offload target(mic: d) nocopy(u)
        {
            printf("u on %d is %x\n", d, u);
            fflush(0);
        }
    }

    return 0;
}

 

I have a server with 2 Intel Xeon Phi installed.

I found an issue is the address of pointer u on device 0 is changed after the malloc on device 1

Here is the output:

Ndev = 2
u on 0 is ac000b30
u on 1 is 60000b30
u on 0 is 60000b30
u on 1 is 60000b30

Then any access operation on u in MIC(device 0) will get segfault as the pointer address is changed.

Please help

 

2 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

This is a defect with data persistence of a local variable in the current (CXE 2013 SP1) release that is fixed in the next major release planned for later this year. It is related to an earlier discussion here.
You can work around this by temporarily using static as in:
    __declspec(target (mic)) static void *u;
The Beta program for the next major release is currently underway. If you interested in participating in our Beta program, please refer to the invitation posted in our User Forum: Invitation to join the Intel® Software Development Tools 2015 Beta program
Our apologies for the inconvenience of this defect.
(Internal tracking id: DPD200245213)

Faça login para deixar um comentário.