iya,
Just trying to compile some very simple examples on my mac. e.g.
#include <stdio.h>
global void foo()
{
}
int main()
{
 foo<<<1,1>>>();
 printf(“CUDA error: %s\n”, cudaGetErrorString(cudaGetLastError())); Â
 return 0;
}
But the nvcc compiler throws up errors like:
test.cu(9): error: expected an expression
test.cu(9): error: unrecognized token
test.cu(10): error: unrecognized token
test.cu(10): error: expected an expression
when I run nvcc --version i get :
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2009 NVIDIA Corporation
Built on Thu_Mar_11_12:08:00_PST_2010
Cuda compilation tools, release 3.0, V0.2.1221
Seems like it’s working fine. I can also run all the example programs provided with the CUDA SDK.
What’s my problem?
Tom
iya,
Just trying to compile some very simple examples on my mac. e.g.
#include <stdio.h>
global void foo()
{
}
int main()
{
 foo<<<1,1>>>();
 printf(“CUDA error: %s\n”, cudaGetErrorString(cudaGetLastError())); Â
 return 0;
}
But the nvcc compiler throws up errors like:
test.cu(9): error: expected an expression
test.cu(9): error: unrecognized token
test.cu(10): error: unrecognized token
test.cu(10): error: expected an expression
when I run nvcc --version i get :
nvcc: NVIDIA ® Cuda compiler driver
Copyright © 2005-2009 NVIDIA Corporation
Built on Thu_Mar_11_12:08:00_PST_2010
Cuda compilation tools, release 3.0, V0.2.1221
Seems like it’s working fine. I can also run all the example programs provided with the CUDA SDK.
What’s my problem?
Tom
tera
November 10, 2010, 8:21pm
3
Can you post the output of [font=“Courier New”]hexdump -C test.cu[/font] ?
It’s just a shot in the dark, but you may have a problem with special symbols or the character encoding used in the file.
tera
November 10, 2010, 8:21pm
4
Can you post the output of [font=“Courier New”]hexdump -C test.cu[/font] ?
It’s just a shot in the dark, but you may have a problem with special symbols or the character encoding used in the file.
Ferguzz
November 11, 2010, 1:03pm
5
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e |#include <stdio.|
00000010 68 3e 0a 0a 5f 5f 67 6c 6f 62 61 6c 5f 5f 20 76 |h>…global v|
00000020 6f 69 64 20 66 6f 6f 28 29 0a 7b 0a 7d 0a 0a 69 |oid foo().{.}…i|
00000030 6e 74 20 6d 61 69 6e 28 29 0a 7b 0a c2 a0 20 66 |nt main().{… f|
00000040 6f 6f 3c 3c 3c 31 2c 31 3e 3e 3e 28 29 3b 0a c2 |oo<<<1,1>>>();…|
00000050 a0 20 70 72 69 6e 74 66 28 22 43 55 44 41 20 65 |. printf(“CUDA e|
00000060 72 72 6f 72 3a 20 25 73 5c 6e 22 2c 20 63 75 64 |rror: %s\n”, cud|
00000070 61 47 65 74 45 72 72 6f 72 53 74 72 69 6e 67 28 |aGetErrorString(|
00000080 63 75 64 61 47 65 74 4c 61 73 74 45 72 72 6f 72 |cudaGetLastError|
00000090 28 29 29 29 3b 20 c2 a0 0a c2 a0 20 72 65 74 75 |())); … retu|
000000a0 72 6e 20 30 3b 0a 7d |rn 0;.}|
000000a7
Cheers
Ferguzz
November 11, 2010, 1:03pm
6
00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e |#include <stdio.|
00000010 68 3e 0a 0a 5f 5f 67 6c 6f 62 61 6c 5f 5f 20 76 |h>…global v|
00000020 6f 69 64 20 66 6f 6f 28 29 0a 7b 0a 7d 0a 0a 69 |oid foo().{.}…i|
00000030 6e 74 20 6d 61 69 6e 28 29 0a 7b 0a c2 a0 20 66 |nt main().{… f|
00000040 6f 6f 3c 3c 3c 31 2c 31 3e 3e 3e 28 29 3b 0a c2 |oo<<<1,1>>>();…|
00000050 a0 20 70 72 69 6e 74 66 28 22 43 55 44 41 20 65 |. printf(“CUDA e|
00000060 72 72 6f 72 3a 20 25 73 5c 6e 22 2c 20 63 75 64 |rror: %s\n”, cud|
00000070 61 47 65 74 45 72 72 6f 72 53 74 72 69 6e 67 28 |aGetErrorString(|
00000080 63 75 64 61 47 65 74 4c 61 73 74 45 72 72 6f 72 |cudaGetLastError|
00000090 28 29 29 29 3b 20 c2 a0 0a c2 a0 20 72 65 74 75 |())); … retu|
000000a0 72 6e 20 30 3b 0a 7d |rn 0;.}|
000000a7
Cheers
tera
November 11, 2010, 3:57pm
7
[font=“Courier New”]00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e |#include <stdio.|
00000010 68 3e 0a 0a 5f 5f 67 6c 6f 62 61 6c 5f 5f 20 76 |h>…global v|
00000020 6f 69 64 20 66 6f 6f 28 29 0a 7b 0a 7d 0a 0a 69 |oid foo().{.}…i|
00000030 6e 74 20 6d 61 69 6e 28 29 0a 7b 0a c2 a0 20 66 |nt main().{… f|
00000040 6f 6f 3c 3c 3c 31 2c 31 3e 3e 3e 28 29 3b 0a c2 |oo<<<1,1>>>();…|
00000050 a0 20 70 72 69 6e 74 66 28 22 43 55 44 41 20 65 |. printf("CUDA e|
00000060 72 72 6f 72 3a 20 25 73 5c 6e 22 2c 20 63 75 64 |rror: %s\n", cud|
00000070 61 47 65 74 45 72 72 6f 72 53 74 72 69 6e 67 28 |aGetErrorString(|
00000080 63 75 64 61 47 65 74 4c 61 73 74 45 72 72 6f 72 |cudaGetLastError|
00000090 28 29 29 29 3b 20 c2 a0 0a c2 a0 20 72 65 74 75 |())); … retu|
000000a0 72 6e 20 30 3b 0a 7d |rn 0;.}|
000000a7
[/font]
You’ve got non-breaking spaces as indentation and as trailing whitespace after the printf() line. I guess the compiler chokes on those. Try deleting and re-inserting the indentation and deleting the trailing space after the printf().
Which editor did you use to create the file?
tera
November 11, 2010, 3:57pm
8
[font=“Courier New”]00000000 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e |#include <stdio.|
00000010 68 3e 0a 0a 5f 5f 67 6c 6f 62 61 6c 5f 5f 20 76 |h>…global v|
00000020 6f 69 64 20 66 6f 6f 28 29 0a 7b 0a 7d 0a 0a 69 |oid foo().{.}…i|
00000030 6e 74 20 6d 61 69 6e 28 29 0a 7b 0a c2 a0 20 66 |nt main().{… f|
00000040 6f 6f 3c 3c 3c 31 2c 31 3e 3e 3e 28 29 3b 0a c2 |oo<<<1,1>>>();…|
00000050 a0 20 70 72 69 6e 74 66 28 22 43 55 44 41 20 65 |. printf("CUDA e|
00000060 72 72 6f 72 3a 20 25 73 5c 6e 22 2c 20 63 75 64 |rror: %s\n", cud|
00000070 61 47 65 74 45 72 72 6f 72 53 74 72 69 6e 67 28 |aGetErrorString(|
00000080 63 75 64 61 47 65 74 4c 61 73 74 45 72 72 6f 72 |cudaGetLastError|
00000090 28 29 29 29 3b 20 c2 a0 0a c2 a0 20 72 65 74 75 |())); … retu|
000000a0 72 6e 20 30 3b 0a 7d |rn 0;.}|
000000a7
[/font]
You’ve got non-breaking spaces as indentation and as trailing whitespace after the printf() line. I guess the compiler chokes on those. Try deleting and re-inserting the indentation and deleting the trailing space after the printf().
Which editor did you use to create the file?
Ferguzz
November 12, 2010, 11:30am
9
Fantastic. Worked a treat. I used TextEdit to create the file. Can you suggest a better simple editor for writing C ?
Thanks,
Tom
Ferguzz
November 12, 2010, 11:30am
10
Fantastic. Worked a treat. I used TextEdit to create the file. Can you suggest a better simple editor for writing C ?
Thanks,
Tom
tera
November 12, 2010, 1:28pm
11
Not a simple one. I use Xcode and sometimes vim.
tera
November 12, 2010, 1:28pm
12
Not a simple one. I use Xcode and sometimes vim.