PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

vector_types.h error when using curand.h

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
pmigz



Joined: 22 Aug 2012
Posts: 1

PostPosted: Wed Aug 22, 2012 8:30 am    Post subject: vector_types.h error when using curand.h Reply with quote

Hi PGI,

I'm trying to use openACC to run a basic Pi estimation code but it will not compile. I'm using a slightly modified version of the code from a pervious forum post:

http://www.pgroup.com/userforum/viewtopic.php?t=3321&sid=3995cf400ec9a0de73260c7fb3a1ba5c

Code:

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <curand.h>
//#include "common.h" //Linux header??

// Iterate over pairs of (x,y) from [0,1] x [0,1]
// Increment pointer only if (x,y) is inside a circle with R = 0.5

long pi(float *dx, float *dy, long n)
{
    long i, s = 0;   
    #pragma acc data deviceptr(dx, dy)
    #pragma acc kernels
    for (i = 0; i < n; i++) {
   float x = dx[i] - 0.5;
   float y = dy[i] - 0.5;
   s += (x*x + y*y < 0.25);
    }
    return s;   
}

int main(int argc, char **argv) {
    float *dx, *dy; // device arrays
    long s; // counter of successful tries
    long n; // number of tries

    if (argc < 2) {
   fprintf(stderr, "Usage: %s N\n", argv[0]);
   return EXIT_FAILURE;
    }

    if ((n = atol(argv[1])) <= 0) {
   fprintf(stderr, "N must be positive\n");
   return EXIT_FAILURE;
    }

    // Allocate memory for device arrays to be filled with random values
    cudaMalloc((void *)&dx, n * sizeof(float));
    cudaMalloc((void *)&dy, n * sizeof(float));

    // Initialize CURAND generator, seed it and generate data
    curandGenerator_t g;
    curandCreateGenerator(&g, CURAND_RNG_PSEUDO_DEFAULT);
    curandSetPseudoRandomGeneratorSeed(g, 0); //TEST SEED ZERO REPLACE WITH time(NULL) when ready.
    curandGenerateUniform(g, dx, n);
    curandGenerateUniform(g, dy, n);
   
    // Perform computations
    s = pi(dx, dy, n);

    // Free memory
    cudaFree(dx);
    cudaFree(dy);
   
    // Print out the result
    printf("%lf\n", (double) s / n * 4.0);
   
    return EXIT_SUCCESS;
       
}


I'm compiling this on a ASUS laptop using on windows 7 (64bit). Nvidia card is a Geforce GT520M. I'm also using PGI accelerator v12.8 (2wk trail version).

When I try to compile this at the command prompt, I recieve the following error.

Code:

PGI$ pgcc -acc -ta=nvidia -Minfo=all openACC_Pi_Estimation_Answer_MOD.c -I "C:\
Program Files\PGI\win64\2012\cuda\4.2\include" -L "C:\Program Files\PGI\win64\2
012\cuda\4.2\lib64"

NOTE: your trial license will expire in 13 days, 22.9 hours.

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 105)
PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier char2 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.h
: 105)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 110)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier uchar2 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.
h: 110)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 125)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier char4 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.h
: 125)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 130)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier uchar4 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.
h: 130)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 145)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier short2 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.
h: 145)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 150)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier ushort2 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types
.h: 150)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 165)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier short4 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.
h: 165)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 166)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier ushort4 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types
.h: 166)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 178)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier int2 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.h:
 178)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 179)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier uint2 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.h
: 179)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 191)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier int4 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.h:
 191)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 196)

PGC-S-0036-Syntax error: Recovery attempted by inserting keyword struct before i
dentifier uint4 (C:\Program Files\PGI\win64\2012\cuda\4.2\include\vector_types.h
: 196)

PGC-S-0037-Syntax error: Recovery attempted by deleting keyword struct (C:\Progr
am Files\PGI\win64\2012\cuda\4.2\include\vector_types.h: 212)

PGC-F-0008-Error limit exceeded (C:\Program Files\PGI\win64\2012\cuda\4.2\includ
e\vector_types.h)
PGC/x86-64 Windows 12.8-0: compilation aborted
PGI$


I haven't seen this error before. I've compiled other openACC programs without an issue on this computer. It's only a problem when utilising curand.h.

Would you happen to have any ideas as to the cause?

Thank you and kind regards,

Paul
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6125
Location: The Portland Group Inc.

PostPosted: Wed Aug 22, 2012 9:31 am    Post subject: Reply with quote

Hi Paul,

pgcc can't compile CUDA C programs. So to get this to work, you need to compile the CUDA C portion with NVCC and the OpenACC portion with pgcc. Also currently we don't support "long" types in reductions. We have an open ticket (TPR#18815) to add this. Finally, I fixed a typo where you need to adjust your cudaMalloc to pass in a "void **". Here's the full example:
Code:


% cat test.cu
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <curand.h>
//#include "common.h" //Linux header??

// Iterate over pairs of (x,y) from [0,1] x [0,1]
// Increment pointer only if (x,y) is inside a circle with R = 0.5
extern "C" {
long pi(float *dx, float *dy, long n);
}

int main(int argc, char **argv) {
    float *dx, *dy; // device arrays
    long s; // counter of successful tries
    long n; // number of tries

    if (argc < 2) {
   fprintf(stderr, "Usage: %s N\n", argv[0]);
   return EXIT_FAILURE;
    }

    if ((n = atol(argv[1])) <= 0) {
   fprintf(stderr, "N must be positive\n");
   return EXIT_FAILURE;
    }

    // Allocate memory for device arrays to be filled with random values
    cudaMalloc((void **) &dx, n * sizeof(float));
    cudaMalloc((void **) &dy, n * sizeof(float));

    // Initialize CURAND generator, seed it and generate data
    curandGenerator_t g;
    curandCreateGenerator(&g, CURAND_RNG_PSEUDO_DEFAULT);
    curandSetPseudoRandomGeneratorSeed(g, 123); //TEST SEED ZERO REPLACE WITH time(NULL) when ready.
    curandGenerateUniform(g, dx, n);
    curandGenerateUniform(g, dy, n);
 
    // Perform computations
    s = pi(dx, dy, n);

    // Print out the result
    printf("%lf\n", (double) s / n * 4.0);

    // Free memory
    cudaFree(dx);
    cudaFree(dy);
   
    return EXIT_SUCCESS;
       
}
% cat pi.c
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
//#include "common.h" //Linux header??

// Iterate over pairs of (x,y) from [0,1] x [0,1]
// Increment pointer only if (x,y) is inside a circle with R = 0.5

long pi(float *dx, float *dy, long n)
{
    long i;   
    int s2=0;

    s2 = 0;
    #pragma acc data deviceptr(dx, dy)
    #pragma acc kernels
    for (i = 0; i < n; i++) {
        float x = dx[i] - 0.5;
        float y = dy[i] - 0.5;
        s2 += (x*x + y*y < 0.25);
     }
    return (long) s2;   
}

% pgcc -c pi.c -Minfo=accel -V12.8 -acc
pi:
     16, Generating compute capability 1.3 binary
         Generating compute capability 2.0 binary
     17, Loop is parallelizable
         Accelerator kernel generated
         17, #pragma acc loop gang, vector(128) /* blockIdx.x threadIdx.x */
             CC 1.3 : 13 registers; 48 shared, 36 constant, 0 local memory bytes
             CC 2.0 : 14 registers; 0 shared, 72 constant, 0 local memory bytes
         20, Sum reduction generated for s2
% nvcc test.cu pi.o -lcurand -L/usr/pgi/linux86-64/12.8/lib -lacc1 -ldl -lpgc -o pi.out
% pi.out 64000
3.142438


Hope this helps,
Mat
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group