error with acc_map_data

I wanted to use acc_map_data and wrote a sample code.
But an error occurred in execution.
Could you teach me how to use acc_map_data?

#include<stdio.h>
#include<stdlib.h>

#define N 10

int main(void)
{
    float *a   = (float*)    malloc(N*sizeof(float));
    float *d_a = (float*)acc_malloc(N*sizeof(float));

    printf("%x, %x\n", a, d_a);

    acc_map_data(a, d_a, N*sizeof(float));

    #pragma acc update device (a[0:N])

    #pragma acc update host(a[0:N])

    acc_unmap_data(a);
    acc_free(d_a);
}



$ pgcc --version

pgcc 15.5-0 64-bit target on x86-64 Linux -tp sandybridge
The Portland Group - PGI Compilers and Tools
Copyright (c) 2015, NVIDIA CORPORATION.  All rights reserved.

$ pgcc -acc  acc_map_data.c
PGC-W-0155-Pointer value created from a nonlong integral type  (acc_map_data.c: 9)
PGC/x86-64 Linux 15.5-0: compilation completed with warnings

$ ./a.out
d7a150, 47c0000
call to cuMemcpyHtoDAsync returned error 1: Invalid value

Hi MIKI Nobuhiro,

You need to include “openacc.h”. Otherwise, C implicit function typing is used and the compiler must assume the return type of “acc_malloc” is an “int” causing the 64-bit pointer to be truncated into 32-bits.

% cat test.c
#include<stdio.h>
#include<stdlib.h>
#include<openacc.h>
#define N 10

int main(void)
{
    float *a   = (float*)    malloc(N*sizeof(float));
    float *d_a = (float*)acc_malloc(N*sizeof(float));

    printf("%x, %x\n", a, d_a);

    acc_map_data(a, d_a, N*sizeof(float));

    #pragma acc update device (a[0:N])

    #pragma acc update host(a[0:N])

    acc_unmap_data(a);
    acc_free(d_a);
}

% pgcc -acc -Minfo=accel -V15.5 test.c ; ./a.out
main:
     17, Generating update device(a[:10])
     19, Generating update host(a[:10])
d19540, 48a0000

Hope this helps,
Mat