# vector\_types.h error when using curand.h

**URL:** <https://forums.developer.nvidia.com/t/vector-types-h-error-when-using-curand-h/133174>\
**Category:** Legacy PGI Compilers (archived)\
**Created:** [August 22, 2012, 3:30pm UTC](https://forums.developer.nvidia.com/t/vector-types-h-error-when-using-curand-h/133174 "2012-08-22T15:30:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmigz](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pmigz](https://forums.developer.nvidia.com/u/pmigz)\
**Post date:** [August 22, 2012, 3:30pm UTC](https://forums.developer.nvidia.com/t/vector-types-h-error-when-using-curand-h/133174/1 "2012-08-22T15:30:25Z")

</div>

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:

> [@using cuda libraries with OpenACC](https://forums.developer.nvidia.com/t/using-cuda-libraries-with-openacc/133091/1):
>
> Hello, Here is an attempt to calculate pi using cuRand and OpenACC. This example works fine with PGI 12.3 and CUDA 4.0. Compiled program by PGI 12.5 and CUDA 4.0 always give 0 as the result. Compiling this example with CUDA 4.1 give the following error: $ make pgcc -acc -ta=nvidia -Minfo=all main.c pi.c -I /opt/pgi/linux86-64/2012/cuda/4.1/include -L /opt/pgi/linux86-64/2012/cuda/4.1/lib64 -lcudart -lcurand -o pi\_acc main.c: PGC-F-0249-#error -- --- !!! UNKNOWN COMPILER: please provide a …

```plaintext
#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.

```plaintext
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

---

<div class="post-metadata">

**Author:** ![MatColgrove](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/matcolgrove/32/14047_2.png) [@MatColgrove](https://forums.developer.nvidia.com/u/MatColgrove)\
**Post date:** [August 22, 2012, 4:31pm UTC](https://forums.developer.nvidia.com/t/vector-types-h-error-when-using-curand-h/133174/2 "2012-08-22T16:31:47Z")

</div>

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:

```nohighlight
% 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
