Hello Philippe,
Thanks for the advise. But I still get the same error.
#include <omp.h>
#include <time.h>
#include <iostream>
void pi()
{
const Int_t kN = 100000000;
long double top = 0.L;
long double bottom = 0.L;
long double kStep = 1.L/kN;
long double sum = 0.L;
#ifndef __CINT__
#pragma omp parallel private(top, bottom)
#endif
{
#ifndef __CINT__
#pragma omp for reduction(+:sum)
#endif
for(Int_t i = 0; i < kN; i++) {
top = 4.L/(1.L + (kStep*i)*(kStep*i));
bottom = 4.L/(1.L + (kStep*(i+1))*(kStep*(i + 1)));
sum += (top + bottom)*kStep/2.L;
root [4] .L pi.C++
Info in <TUnixSystem::ACLiC>: creating shared library /Users/oxon/./pi_C.so
In file included from /Users/oxon/pi_C_ACLiC_dict.h:34,
from /Users/oxon/pi_C_ACLiC_dict.cxx:16:
/Users/oxon/./pi.C: In function ‘void pi()’:
/Users/oxon/./pi.C:14: error: expected ‘#pragma omp’ clause before ‘public’
i686-apple-darwin10-g++-4.2.1: /Users/oxon/pi_C_ACLiC_dict.o: No such file or directory
Error in <ACLiC>: Compilation failed!
Regards,
--
OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu}
Institute of Space and Astronautical Science (ISAS/JAXA)
Now at KIPAC/SLAC/Stanford
Varian Physics #306
382 Via Pueblo Mall, MC 406 Stanford, CA94305
TEL 650-736-0971/FAX 650-724-5065
Skype : okumura.akira
On 2010/09/15, at 8:53, Philippe Canal wrote:
> Hi,
>
> You need to at least hide the #pragma from CINT:
>
> #ifndef __CINT__
> #pragma omp parallel private(top, bottom)
> #endif
> {
> #ifndef __CINT__
> #pragma omp for reduction(+:sum)
> #endif
> for(Int_t i = 0; i < kN; i++) {
>
> Cheers,
> Philippe.
>
> On 9/15/10 10:47 AM, OKUMURA, Akira wrote:
>> Hello ROOTers,
>>
>> Does ACLiC support OpenMP?
>>
>> I started learning OpenMP to improve the speed of my analysis. The following is an example to calculate pi with OpenMP.
>>
>> === pi.C ===
>> #include <omp.h>
>> #include <time.h>
>> #include <iostream>
>>
>> void pi()
>> {
>> const Int_t kN = 100000000;
>> long double top = 0.L;
>> long double bottom = 0.L;
>> long double kStep = 1.L/kN;
>> long double sum = 0.L;
>>
>> #pragma omp parallel private(top, bottom)
>> {
>> #pragma omp for reduction(+:sum)
>> for(Int_t i = 0; i < kN; i++) {
>> top = 4.L/(1.L + (kStep*i)*(kStep*i));
>> bottom = 4.L/(1.L + (kStep*(i+1))*(kStep*(i + 1)));
>> sum += (top + bottom)*kStep/2.L;
>> } // i
>> }
>> std::cout.precision(16);
>> std::cout << "pi = " << sum << "\n";
>> }
>> ============
>>
>> But I got the following error.
>> ============
>> root [0] gSystem->SetIncludePath("-fopenmp")
>> root [1] gSystem->AddLinkedLibs("-lgomp")
>> root [2] .L pi.C+O
>> Info in <TUnixSystem::ACLiC>: creating shared library /Users/oxon/./pi_C.so
>> In file included from /Users/oxon/pi_C_ACLiC_dict.h:34,
>> from /Users/oxon/pi_C_ACLiC_dict.cxx:16:
>> /Users/oxon/./pi.C: In function ‘void pi()’:
>> /Users/oxon/./pi.C:13: error: expected ‘#pragma omp’ clause before ‘public’
>> i686-apple-darwin10-g++-4.2.1: /Users/oxon/pi_C_ACLiC_dict.o: No such file or directory
>> Error in <ACLiC>: Compilation failed!
>> ============
>>
>> It seems that some of OpenMP words are not handled properly in generation of a dictionary. I suppose ACLiC does not support OpenMP yet.
>>
>> If ACLiC supports OpenMP, how can I run the script in ROOT? This example runs as I expected in standalone C++ program.
>>
>> I am using ROOT trunk and GCC (i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5664)) on Snow Leopard.
>>
>> Regards,
>>
>> --
>> OKUMURA, Akira oxon@{astro.isas.jaxa.jp,stanford.edu}
>> Institute of Space and Astronautical Science (ISAS/JAXA)
>> Now at KIPAC/SLAC/Stanford
>> Varian Physics #306
>> 382 Via Pueblo Mall, MC 406 Stanford, CA94305
>> TEL 650-736-0971/FAX 650-724-5065
>> Skype : okumura.akira
>>
Received on Wed Sep 15 2010 - 18:25:45 CEST
This archive was generated by hypermail 2.2.0 : Wed Sep 15 2010 - 23:50:02 CEST