CUDA: argument of type float * is incompatible with parameter of type float (*)[32768]

darkfall94

On passing my pointer to point to the array, I am getting the foll error: argument of type "float " is incompatible with parameter of type "float ()[32768]

relevant Snippets of my code are:

#define N  32768

__global__ void op(float k_a[][N])
{
 //some operation
}
float *ptr_a=(float*)malloc(N*N*sizeof(float));

float *d_ptr_a;cudaMalloc((void**)&d_ptr_a,N*N*sizeof(float));

cudaMemcpy(d_ptr_a,ptr_a,N*N*sizeof(float),cudaMemcpyHostToDevice);

op<<<nblocks,nthreadsperblock>>>(d_ptr_a)

Can some tell me whats going wrong? I am a beginner to CUDA.

Matso

What we have here is an incorrect use of pointers and arrays. According to the definition of the routine op it requires a pointer to array of length N of type float. On the other hand when it is called a pointer to type float is provided as an argument, thus resulting in an error message of types not being compatible.

If op routine is to tackle with a 2D array of float values, it is better to have its argument be a pointer to float. In such a case all of the M "rows" of the original 2D array, accessed with an index y, sit in the memory one after another, in a single line, like that:

[row0][row1][row2]...[rowM-1]

Every such row contains N "columns", accessed by index x. To get a value for some pair (x, y) we have to produce a global index that will access the 1D array:

index = y * N + x;

Simple as that.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Argument of type "char *" is incompatible with parameter of type "LPWSTR"

From Dev

CUDA: argument of type "float" is incompatible with parameter of type "void *"

From Dev

Sending 'CGFloat' (aka 'float') to parameter incompatible type 'CGSize' (aka 'struct CGSize')

From Dev

Error: argument of type "HNode *" is incompatible with parameter type "HNode *"

From Dev

Incompatible pointer types passing retainable parameter of type 'float [2]'to a CF function expecting 'const CGFloat *' (aka 'const double *') type

From Dev

incompatible type for argument 1

From Dev

Why is an argument of type double ** incompatible with a parameter of type const double **

From Dev

Argument of type "const char **" is incompatible with parameter of type "const char *"

From Dev

IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR"

From Dev

Sending float to parameter of incompatible type id

From Dev

float type with . and ,

From Dev

Argument of type 'const char*' is incompatible with parameter of type 'char*'

From Dev

TypeError: argument of type 'float' is not iterable

From Dev

IntelliSense: argument of type "_TCHAR *" is incompatible with parameter of type "const char *"

From Dev

Error: Sending 'float[3]' to parameter of incompatible type 'float'

From Dev

Sending 'CGFloat' (aka 'float') to parameter incompatible type 'CGSize' (aka 'struct CGSize')

From Dev

argument of type "int *" is incompatible with parameter of type "int (*)[1000]"

From Dev

Error: argument of type "HNode *" is incompatible with parameter type "HNode *"

From Dev

OpenGL C++ Argument of type void is incompatible with parameter of type void(*)()

From Dev

Xcode error: "passing 'float' to parameter of incompatible type id"

From Dev

Operand type clash geography is incompatible with float

From Dev

Argument of type "const char **" is incompatible with parameter of type "const char *"

From Dev

Sending float to parameter of incompatible type id

From Dev

float type with . and ,

From Dev

Argument of type "int" is incompatible with parameter of type "int *"

From Dev

argument of type "char *" is incompatible with parameter of type "LPCWSTR"

From Dev

note: expected 'float *' but argument is of type 'int *'

From Dev

"argument of type ”int(*)()“ is incompatible with parameter of type int" error?

From Dev

Argument of type "const char*" is incompatible with parameter of type "Person"

Related Related

  1. 1

    Argument of type "char *" is incompatible with parameter of type "LPWSTR"

  2. 2

    CUDA: argument of type "float" is incompatible with parameter of type "void *"

  3. 3

    Sending 'CGFloat' (aka 'float') to parameter incompatible type 'CGSize' (aka 'struct CGSize')

  4. 4

    Error: argument of type "HNode *" is incompatible with parameter type "HNode *"

  5. 5

    Incompatible pointer types passing retainable parameter of type 'float [2]'to a CF function expecting 'const CGFloat *' (aka 'const double *') type

  6. 6

    incompatible type for argument 1

  7. 7

    Why is an argument of type double ** incompatible with a parameter of type const double **

  8. 8

    Argument of type "const char **" is incompatible with parameter of type "const char *"

  9. 9

    IntelliSense: argument of type "const char *" is incompatible with parameter of type "LPCWSTR"

  10. 10

    Sending float to parameter of incompatible type id

  11. 11

    float type with . and ,

  12. 12

    Argument of type 'const char*' is incompatible with parameter of type 'char*'

  13. 13

    TypeError: argument of type 'float' is not iterable

  14. 14

    IntelliSense: argument of type "_TCHAR *" is incompatible with parameter of type "const char *"

  15. 15

    Error: Sending 'float[3]' to parameter of incompatible type 'float'

  16. 16

    Sending 'CGFloat' (aka 'float') to parameter incompatible type 'CGSize' (aka 'struct CGSize')

  17. 17

    argument of type "int *" is incompatible with parameter of type "int (*)[1000]"

  18. 18

    Error: argument of type "HNode *" is incompatible with parameter type "HNode *"

  19. 19

    OpenGL C++ Argument of type void is incompatible with parameter of type void(*)()

  20. 20

    Xcode error: "passing 'float' to parameter of incompatible type id"

  21. 21

    Operand type clash geography is incompatible with float

  22. 22

    Argument of type "const char **" is incompatible with parameter of type "const char *"

  23. 23

    Sending float to parameter of incompatible type id

  24. 24

    float type with . and ,

  25. 25

    Argument of type "int" is incompatible with parameter of type "int *"

  26. 26

    argument of type "char *" is incompatible with parameter of type "LPCWSTR"

  27. 27

    note: expected 'float *' but argument is of type 'int *'

  28. 28

    "argument of type ”int(*)()“ is incompatible with parameter of type int" error?

  29. 29

    Argument of type "const char*" is incompatible with parameter of type "Person"

HotTag

Archive