Source to source for reduction clause - clang

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Source to source for reduction clause - clang

Victor Leschuk via cfe-dev
Hello,

I am new to clang and this problem may be so easy, but it took lots of my time. I am writing a source to source translator by clang for translating from my MetaFork language to OpenMP. I want to translate:
----------------------------------
meta_for reduction[+: var] (int i=0; i<10; i++)

to 

#pragma omp parallel for reduction (+: var) 
           for (int i=0; i< 10; i++)
----------------------------------
What I did to this point, I defined "meta_for" to be "#pragma omp parallel for for" and managed to add a "tok::eod" between two for's in preprocessor. So now, I can translate 
----------------------------------
meta_for (int i=0; i<10; i++)

to 

#pragma omp parallel for 
           for (int i=0; i< 10; i++)
----------------------------------

But when I add reduction clause to meta_for, my idea is to comment out " reduction[+: var]" and have a complete parallel for loop, also save the location of reduction clause and operation and variables for later. But when I change the token kind of "reduction", "[", ... , "]" to tok::comment. It gives me a weird error.

It says  expected to have ")" after "int" to be matched with "("!!!

can anyone help me on that?

Thank you. 

--
------
----------
Masoud Ataei (Mr.)


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Source to source for reduction clause - clang

Victor Leschuk via cfe-dev
Why not change the token kind of "reduction", "[", ... , "]" to tok::unknown? I suspect tok::comment might do something bad to your one-line "meta_for reduction[+: var] (int i=0; i<10; i++)".

Regards,
chenwj

2017-05-18 2:25 GMT+08:00 Masoud Ataei via cfe-dev <[hidden email]>:
Hello,

I am new to clang and this problem may be so easy, but it took lots of my time. I am writing a source to source translator by clang for translating from my MetaFork language to OpenMP. I want to translate:
----------------------------------
meta_for reduction[+: var] (int i=0; i<10; i++)

to 

#pragma omp parallel for reduction (+: var) 
           for (int i=0; i< 10; i++)
----------------------------------
What I did to this point, I defined "meta_for" to be "#pragma omp parallel for for" and managed to add a "tok::eod" between two for's in preprocessor. So now, I can translate 
----------------------------------
meta_for (int i=0; i<10; i++)

to 

#pragma omp parallel for 
           for (int i=0; i< 10; i++)
----------------------------------

But when I add reduction clause to meta_for, my idea is to comment out " reduction[+: var]" and have a complete parallel for loop, also save the location of reduction clause and operation and variables for later. But when I change the token kind of "reduction", "[", ... , "]" to tok::comment. It gives me a weird error.

It says  expected to have ")" after "int" to be matched with "("!!!

can anyone help me on that?

Thank you. 

--
------
----------
Masoud Ataei (Mr.)


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...