Sehen Sie diese Funktion (Matrix-Vektor-Produkt):OpenMP: vorbestimmt "geteilt" für "geteilt"?
std::vector<double> times(std::vector<std::vector<double> > const& A, std::vector<double> const& b, int m, int n) {
std::vector<double> c;
c.resize(n);
int i, j;
double sum;
#pragma omp parallel for default(none) private(i, j, sum) shared(m, n, A, b, c)
for (i = 0; i < m; ++i) {
sum = 0.0;
for (j = 0; j < n; j++) {
sum += A[i][j] * b[j];
}
c[i] = sum;
}
return c;
}
Beim Versuch, dies mit OpenMP zu kompilieren, der Compiler nicht mit:
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -fopenmp -MMD -MP -MF"src/OpemMPTutorial.d" -MT"src/OpemMPTutorial.d" -o "src/OpemMPTutorial.o" "../src/OpemMPTutorial.cpp"
../src/OpemMPTutorial.cpp:127: warning: ignoring #pragma omp end
../src/OpemMPTutorial.cpp: In function 'std::vector<double, std::allocator<double> > times(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > >&, std::vector<double, std::allocator<double> >&, int, int)':
../src/OpemMPTutorial.cpp:200: error: 'b' is predetermined 'shared' for 'shared'
../src/OpemMPTutorial.cpp:200: error: 'A' is predetermined 'shared' for 'shared'
make: *** [src/OpemMPTutorial.o] Error 1
Was ist hier falsch ist?
(Beachten Sie, dass nur in dem gleichen Fehler die const
Ergebnisse zu entfernen.)
Ich kompilierte Ihre Funktion ohne Probleme mit 'g ++ 4.6.3'. – Massimiliano
Ich benutze 'i686-apple-darwin11-llvm-gcc-4.2'. Es könnte ein Problem mit dieser Compiler-Version sein. Ich versuche auf gcc 4.7 zu aktualisieren – clstaudt
@cls: Ich habe Witze gemacht. Ich benutze OpenMP nicht und habe daher diesen GCC-Fehler vorher noch nie gesehen. Du hast also eine positive Bewertung bekommen, nur weil du mir einen neuen GCC-Fehler gegeben hast (du hast das nicht wirklich). –