CUDA compiling error - expected an identifier





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















When I try to execute the following code, I get errors :



#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>

__global__ void vecAdd(int *A, int *B, int *C)
{
int id = threadIdx.x;
C[id] = A[id] + B[id];
}

int main()
{
printf("Enter the dimenstions of A");
int n;
scanf("%d", &n);
int A[n], B[n], C[n];
printf("Enter the elements of A: n");
for(int i = 0; i < n; i++)
{
scanf("%d", &A[i]);
}

printf("Enter the elements of B: n");
for(int i = 0; i < n; i++)
{
scanf("%d", &B[i]);
}

int *dA, *dB, *dC;
cudaMalloc((void **)&dA, n*sizeof(int));
cudaMalloc((void **)&dB, n*sizeof(int));
cudaMalloc((void **)&dC, n*sizeof(int));

cudaMemcpy(dA, A, n*sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dB, B, n*sizeof(int), cudaMemcpyHostToDevice);

vecAdd<<<1,n>>>(dA, dB, dC);

cudaMemcpy(C, dC, n*sizeof(int), cudaMemcpyDeviceToHost);

for(int i = 0; i < n; i ++)
{
printf("%d t", C[i]);

}
}




The errors I get are :



/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: expected an identifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: expected a type specifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: explicit type is missing ("int" assumed)

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: expected an identifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: expected a type specifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: explicit type is missing ("int" assumed)

/usr/include/x86_64-linux-gnu/bits/byteswap.h(47): error: identifier "__builtin_bswap32" is undefined

/usr/include/x86_64-linux-gnu/bits/byteswap.h(111): error: identifier "__builtin_bswap64" is undefined

/usr/include/c++/5/bits/cpp_type_traits.h(270): error: identifier "__int128" is undefined

/usr/include/c++/5/bits/cpp_type_traits.h(270): error: expected a ">"

/usr/include/c++/5/cstdlib(178): error: identifier "__int128" is undefined

/usr/include/c++/5/cstdlib(179): error: identifier "__int128" is undefined

12 errors detected in the compilation of "/tmp/tmpxft_0000200c_00000000-4_temp2.cpp1.ii".


Any help is deeply appreciated. Thanks!










share|improve this question


















  • 1





    Make sure you are using a supported GCC/G++ compiler for your CUDA version: see NVIDIA CUDA Installation Guide for Linux

    – steeldriver
    Mar 29 at 14:20











  • Thanks for the reply! I've checked it, the version specified and the version I am using match exactly. Is there any other reason why this error might occur?

    – my_cse lab
    Mar 29 at 17:51


















0















When I try to execute the following code, I get errors :



#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>

__global__ void vecAdd(int *A, int *B, int *C)
{
int id = threadIdx.x;
C[id] = A[id] + B[id];
}

int main()
{
printf("Enter the dimenstions of A");
int n;
scanf("%d", &n);
int A[n], B[n], C[n];
printf("Enter the elements of A: n");
for(int i = 0; i < n; i++)
{
scanf("%d", &A[i]);
}

printf("Enter the elements of B: n");
for(int i = 0; i < n; i++)
{
scanf("%d", &B[i]);
}

int *dA, *dB, *dC;
cudaMalloc((void **)&dA, n*sizeof(int));
cudaMalloc((void **)&dB, n*sizeof(int));
cudaMalloc((void **)&dC, n*sizeof(int));

cudaMemcpy(dA, A, n*sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dB, B, n*sizeof(int), cudaMemcpyHostToDevice);

vecAdd<<<1,n>>>(dA, dB, dC);

cudaMemcpy(C, dC, n*sizeof(int), cudaMemcpyDeviceToHost);

for(int i = 0; i < n; i ++)
{
printf("%d t", C[i]);

}
}




The errors I get are :



/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: expected an identifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: expected a type specifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: explicit type is missing ("int" assumed)

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: expected an identifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: expected a type specifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: explicit type is missing ("int" assumed)

/usr/include/x86_64-linux-gnu/bits/byteswap.h(47): error: identifier "__builtin_bswap32" is undefined

/usr/include/x86_64-linux-gnu/bits/byteswap.h(111): error: identifier "__builtin_bswap64" is undefined

/usr/include/c++/5/bits/cpp_type_traits.h(270): error: identifier "__int128" is undefined

/usr/include/c++/5/bits/cpp_type_traits.h(270): error: expected a ">"

/usr/include/c++/5/cstdlib(178): error: identifier "__int128" is undefined

/usr/include/c++/5/cstdlib(179): error: identifier "__int128" is undefined

12 errors detected in the compilation of "/tmp/tmpxft_0000200c_00000000-4_temp2.cpp1.ii".


Any help is deeply appreciated. Thanks!










share|improve this question


















  • 1





    Make sure you are using a supported GCC/G++ compiler for your CUDA version: see NVIDIA CUDA Installation Guide for Linux

    – steeldriver
    Mar 29 at 14:20











  • Thanks for the reply! I've checked it, the version specified and the version I am using match exactly. Is there any other reason why this error might occur?

    – my_cse lab
    Mar 29 at 17:51














0












0








0








When I try to execute the following code, I get errors :



#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>

__global__ void vecAdd(int *A, int *B, int *C)
{
int id = threadIdx.x;
C[id] = A[id] + B[id];
}

int main()
{
printf("Enter the dimenstions of A");
int n;
scanf("%d", &n);
int A[n], B[n], C[n];
printf("Enter the elements of A: n");
for(int i = 0; i < n; i++)
{
scanf("%d", &A[i]);
}

printf("Enter the elements of B: n");
for(int i = 0; i < n; i++)
{
scanf("%d", &B[i]);
}

int *dA, *dB, *dC;
cudaMalloc((void **)&dA, n*sizeof(int));
cudaMalloc((void **)&dB, n*sizeof(int));
cudaMalloc((void **)&dC, n*sizeof(int));

cudaMemcpy(dA, A, n*sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dB, B, n*sizeof(int), cudaMemcpyHostToDevice);

vecAdd<<<1,n>>>(dA, dB, dC);

cudaMemcpy(C, dC, n*sizeof(int), cudaMemcpyDeviceToHost);

for(int i = 0; i < n; i ++)
{
printf("%d t", C[i]);

}
}




The errors I get are :



/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: expected an identifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: expected a type specifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: explicit type is missing ("int" assumed)

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: expected an identifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: expected a type specifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: explicit type is missing ("int" assumed)

/usr/include/x86_64-linux-gnu/bits/byteswap.h(47): error: identifier "__builtin_bswap32" is undefined

/usr/include/x86_64-linux-gnu/bits/byteswap.h(111): error: identifier "__builtin_bswap64" is undefined

/usr/include/c++/5/bits/cpp_type_traits.h(270): error: identifier "__int128" is undefined

/usr/include/c++/5/bits/cpp_type_traits.h(270): error: expected a ">"

/usr/include/c++/5/cstdlib(178): error: identifier "__int128" is undefined

/usr/include/c++/5/cstdlib(179): error: identifier "__int128" is undefined

12 errors detected in the compilation of "/tmp/tmpxft_0000200c_00000000-4_temp2.cpp1.ii".


Any help is deeply appreciated. Thanks!










share|improve this question














When I try to execute the following code, I get errors :



#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>
#include <stdlib.h>

__global__ void vecAdd(int *A, int *B, int *C)
{
int id = threadIdx.x;
C[id] = A[id] + B[id];
}

int main()
{
printf("Enter the dimenstions of A");
int n;
scanf("%d", &n);
int A[n], B[n], C[n];
printf("Enter the elements of A: n");
for(int i = 0; i < n; i++)
{
scanf("%d", &A[i]);
}

printf("Enter the elements of B: n");
for(int i = 0; i < n; i++)
{
scanf("%d", &B[i]);
}

int *dA, *dB, *dC;
cudaMalloc((void **)&dA, n*sizeof(int));
cudaMalloc((void **)&dB, n*sizeof(int));
cudaMalloc((void **)&dC, n*sizeof(int));

cudaMemcpy(dA, A, n*sizeof(int), cudaMemcpyHostToDevice);
cudaMemcpy(dB, B, n*sizeof(int), cudaMemcpyHostToDevice);

vecAdd<<<1,n>>>(dA, dB, dC);

cudaMemcpy(C, dC, n*sizeof(int), cudaMemcpyDeviceToHost);

for(int i = 0; i < n; i ++)
{
printf("%d t", C[i]);

}
}




The errors I get are :



/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: expected an identifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: expected a type specifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(218): error: explicit type is missing ("int" assumed)

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: expected an identifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: expected a type specifier

/usr/include/x86_64-linux-gnu/c++/5/bits/c++config.h(222): error: explicit type is missing ("int" assumed)

/usr/include/x86_64-linux-gnu/bits/byteswap.h(47): error: identifier "__builtin_bswap32" is undefined

/usr/include/x86_64-linux-gnu/bits/byteswap.h(111): error: identifier "__builtin_bswap64" is undefined

/usr/include/c++/5/bits/cpp_type_traits.h(270): error: identifier "__int128" is undefined

/usr/include/c++/5/bits/cpp_type_traits.h(270): error: expected a ">"

/usr/include/c++/5/cstdlib(178): error: identifier "__int128" is undefined

/usr/include/c++/5/cstdlib(179): error: identifier "__int128" is undefined

12 errors detected in the compilation of "/tmp/tmpxft_0000200c_00000000-4_temp2.cpp1.ii".


Any help is deeply appreciated. Thanks!







cuda






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 29 at 12:29









my_cse labmy_cse lab

62




62








  • 1





    Make sure you are using a supported GCC/G++ compiler for your CUDA version: see NVIDIA CUDA Installation Guide for Linux

    – steeldriver
    Mar 29 at 14:20











  • Thanks for the reply! I've checked it, the version specified and the version I am using match exactly. Is there any other reason why this error might occur?

    – my_cse lab
    Mar 29 at 17:51














  • 1





    Make sure you are using a supported GCC/G++ compiler for your CUDA version: see NVIDIA CUDA Installation Guide for Linux

    – steeldriver
    Mar 29 at 14:20











  • Thanks for the reply! I've checked it, the version specified and the version I am using match exactly. Is there any other reason why this error might occur?

    – my_cse lab
    Mar 29 at 17:51








1




1





Make sure you are using a supported GCC/G++ compiler for your CUDA version: see NVIDIA CUDA Installation Guide for Linux

– steeldriver
Mar 29 at 14:20





Make sure you are using a supported GCC/G++ compiler for your CUDA version: see NVIDIA CUDA Installation Guide for Linux

– steeldriver
Mar 29 at 14:20













Thanks for the reply! I've checked it, the version specified and the version I am using match exactly. Is there any other reason why this error might occur?

– my_cse lab
Mar 29 at 17:51





Thanks for the reply! I've checked it, the version specified and the version I am using match exactly. Is there any other reason why this error might occur?

– my_cse lab
Mar 29 at 17:51










0






active

oldest

votes












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1129679%2fcuda-compiling-error-expected-an-identifier%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1129679%2fcuda-compiling-error-expected-an-identifier%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How did Captain America manage to do this?

迪纳利

南乌拉尔铁路局