나는 .c
파일 하나와 .cu
파일 두 개, nn.cu
및 parallel.cu
의 파일로 구성된 프로그램을 운영하고 있습니다. 주 기능은 .cu
파일에 있으며 nn.cu
과 .c
파일 (utils.c
)은 에 extern "C"
으로 있습니다. 본인은 (cilk
없이 완벽하게 실행) 프로그램을 병렬화 할, 그래서 나는 _Cilk_spawn
과 _Cilk_sync
으로, cilk
을 고려 :Cilk와 CUDA 조합 및 편집
int main(int argc, char* argv[]) {
clock_t begin = clock();
srand((unsigned)time(NULL));
int n_inputs = atoi(argv[2]);
int n_hidden = atoi(argv[3]);
int n_outputs = atoi(argv[4]);
// Build output layer
NeuralNet nn = buildNeuralNet(n_inputs, n_outputs, n_hidden);
// Build training samples
int _p1[] = {0,0};
Pattern p1 = makePatternSingleOutput(_p1, 0);
int _p2[] = {0,1};
Pattern p2 = makePatternSingleOutput(_p2, 1);
int _p3[] = {1,1};
Pattern p3 = makePatternSingleOutput(_p3, 1);
int _p4[] = {1,0};
Pattern p4 = makePatternSingleOutput(_p4, 1);
Pattern patterns[] = {p3, p2, p1, p4};
// Train the network
_Cilk_spawn train_network(patterns, 4, atoi(argv[1]), nn);
printf("\n\nTesting the network\n");
_Cilk_sync;
_Cilk_spawn update_pattern(p2, nn);
for (int i=0; i < nn.n_outputs; i++) {
printf("Output: %f, expected: %i\n", nn.out_output[i], p2.result[i]);
printf("NN Error : %f\n", 1.0f - nn.out_output[i]);
}
cudaDeviceReset();
_Cilk_sync;
clock_t end = clock();
double time_spent = (double)(end - begin)/CLOCKS_PER_SEC;
printf("Runtime : %f\n", time_spent);
return 0;
}
내가 nvcc
과 함께 모든 컴파일 할 때 문제는 다음과 같습니다
$ nvcc -Wno-deprecated-gpu-targets -o my_nn_cilk nn.cu parallel.cu -lm
nn.cu(241): error: identifier "_Cilk_spawn" is undefined
nn.cu(241): error: expected a ")"
nn.cu(245): error: identifier "_Cilk_sync" is undefined
nn.cu(247): error: identifier "_Cilk_spawn" is undefined
nn.cu(247): error: expected a ")"
5 errors detected in the compilation of "/tmp/tmpxft_00003b52_00000000-14_nn.cpp1.ii".
I _Cilk_spawn
이라는 두 가지 기능은 원하는 CUDA
커널을 호출합니다. nvcc
명령에 -lcilkrts
매개 변수를 추가해도 오류는 동일합니다. 또한 코드 시작 부분에 #include "cilk/cilk.h"
이 있습니다.
도와주세요. 왜이 오류가 표시되고 컴파일되지 않습니까? 미리 감사드립니다.
나는 이것을 시도 할 것이다, 고마워! – BabisI