This project has been phased out since we have a new OpenMP
implementation in src/midend/ompLowering.
Please refer to the ROSE Manual's "OpenMP Support" Chapter for 
details. 
http://www.rosecompiler.org/ROSE_UserManual/ROSE-UserManual.pdf


We keep this directory just for testing purpose.
Don't use any work from this directory!!!

By Liao, 10/23/2009
-------------------------------------------

The ROSE OpenMP Translator V 0.9

By Chunhua(Leo) Liao, University of Houston, @ LLNL
August, 2006

======================================================

This is an OpenMP translator using the ROSE compiler framework.
It takes OpenMP code as input and generates multi-threaded code
with runtime library calls to the Omni OpenMP runtime library.

-------------------------------------------------------
Major features
-------------------------------------------------------
Implemented OpenMP 2.5 constructs:
  omp parallel,
  omp for,
  schedule(static/dynamic/guided/runtime, [chunksize]),
  omp sections,
  private, firstprivate, lastprivate, 
  reduction(+:), 
  threadprivate(file-scope, built-in type and arrays),
  copyin
  nowait,
  omp single,
  omp master,
  omp critical(no name),
  omp barrier
  omp flush

C++ OpenMP features:
   'omp parallel' within member functions
   tested private, shared, firstprivate on class objects.

Not yet supported constructs:
  ordered, num_threads,
  copyprivate

-------------------------------------------------------
What is in the package
-------------------------------------------------------

*Key files:
  main.C:    source code for the ROSE OpenMP translator 
  ompcLib.h: internal header of translated code to Omni RTL's interface
  omp.h:     user level OpenMP header
  libompc.a: prebuilt Omni's OpenMP runtime library binary for
	     IA32-Red Hat Enterprise Linux WS release 3 (Taroon Update 7)
  Makefile: makefile for the translator and some c test input

*Docs:
  README:  user guide

*Tests:
  cppmakefile: makefile for C++ test input

  input*.c/C  : c/C++ test input
  ctor-X.C  tests from GCC gomp
  inputBugXX.c some regression tests

-------------------------------------------------------
How to build the translator
-------------------------------------------------------
* Preparation: 
ROSE is needed to build this OpenMP translator (main.C)

Refer to ROSE manual to build and install ROSE. We recommend to use separated directories for source code, build path and installation path. For example:

  $HOME/ROSE:   ROSE source tree
  $HOME/buildrose: build directory for ROSE
  $HOME/opt/rose: installation path for ROSE

* Build: 
Assuming this package is named OpenMPtranslation.tar.gz:

To generate the translator, untar the package first.

Enter OpenMPtranslation/ and set the right paths mentioned above for ROSE in Makefile and type:
 	gmake translator

It will in turn calls the following commands:

g++ -g -I/home/liao6/opt/rose/include -c -o main.o \
     ./main.C
g++ -g -o roseomp main.o -L/home/liao6/buildrose/src -Wl,-rpath /home/liao6/buildrose/src -lrose -ledg -lfl   -lm $(RT_LIBS)

'roseomp' is the generated executable translator.

* clean up 
  gmake clean

-------------------------------------------------------
How to use the translator
-------------------------------------------------------
The translator 'roseomp' needs two headers (omp.h,ompcLib.h) and the Omni OpenMP runtime library (libompc.a) to fully compile and run OpenMP programs.

* Preparing the OpenMP Runtime library
Omni's OpenMP runtime library servers as the current target RTL for ROSE OpenMP translator. You can use the prebuilt libompc.a in the package or build it by yourself(recommended). 

First install the Java support:
   source /usr/apps/java/default/setup.csh

Below is the instructions of building Omni's RTL by yourself.

Download Omni 1.6 from http://phase.hpcc.jp/Omni/, 
Or directly http://www.hpcc.jp/Omni/ftp/Omni/Omni-1.6.tar.gz

Omni RTL supports tracing by using a tracing library. We can disable it to avoid linking the extra tracing library. So undefine USE_LOG at line 28 of Omni-1.6/lib/libompc/ompclib.h

//#define USE_LOG 1
// We do not want to use log yet

 #ifdef USE_LOG
 #undef USE_LOG
 #endif

Configure –prefix=/yourOmniInstallationPath, 
build and install Omni compiler as instructed by its manual.
 
The Omni OpenMP RTL is /yourOmniInstallationPath/omni/lib/openmp/lib/libompc.a

* Test the translator and the Omni RTL: 

There are some toy c test inputs to test the translator. Static linking with libompc.a is used for simplicity.
 
Set ROSE_INPUT in the makefile to select the desired test and type

    gmake test
The possible screen output should like the following:

  ./roseomp -c -D_OPENMP -I/home/liao6/OpenMPtranslation inputHello.c
  ./roseomp -o inputHello.out inputHello.o -L/home/liao6/opt/omni/lib/openmp/lib -lompc -lpthread -lm
  ./inputHello.out
	Hello,world!
	1Hello,world!
	2Hello,world!

The makefile for C++ test input is cppmake. Set ROSE_INPUT in it to choose the desired test input and type
  gmake -f cppmakefile

* Compile your own code

Assuming you have the ROSE OpenMP translator (roseomp) and its headers (omp.h,ompcLib.h) at $HOME/OpenMPtranslation. You also have Omni's RTL (libompc.a) at $(HOME)/opt/omni/lib/openmp/lib/ .

Then you need to modify your makefile using flags like:
  TRANSLATOR_PATH =$(HOME)/OpenMPtranslation
  RTL_PATH= $(HOME)/opt/omni/lib/openmp/lib/
  # or use the prebuilt libompc.a instead
  #RTL_PATH= $(HOME)/OpenMPtranslation 

  CC = $(TRANSLATOR_PATH)/roseomp
  CFLAGS =-D_OPENMP -I$(TRANSLATOR_PATH)
  # using C only mode 
  #CFLAGS =-D_OPENMP -I$(TRANSLATOR_PATH) -rose:C_only
  CLINKFLAGS  = -L$(RTL_PATH) -lompc -lpthread -lm

cppmakefile in the package is a good example about how to set and use the flags.

* examine the translated code

For any input c/C++ file(foo.c or foo.C), the translator will keep a translated file as rose_foo.c or rose_foo.C. You can look into the translated code to check if the translation is correct or just for curiosity.

-------------------------------------------------------
Limitations & known issues
-------------------------------------------------------
* The translator works in C++ mode by default. So some OpenMP C code needs to be slightly changed to pass the compilation if the default C++ is preferred. The C mode of this translator has not yet been thoroughly tested yet. 

* Only + operation of reduction has been implemented so far due to time limit.

* Preprocessing information(#include, #ifdef #endif, etc) might get lost after the translation. 

-------------------------------------------------------
Bug report and comments
-------------------------------------------------------
liaoch@cs.uh.edu

-------------------------------------------------------
Acknowledgement:
-------------------------------------------------------
* This code borrows some good ideas from other OpenMP compilers such as Omni and OpenUH.
                                                                                         
[Omni] Mitsuhisa Sato, Shigehisa Satoh, Kazuhiro Kusano, and Yoshio Tanaka. Design of OpenMP compiler for an SMP cluster. In Proc. of the 1st European Workshop on OpenMP, September 1999. 32-39
                                                                                         
[OpenUH]Chunhua Liao, Oscar Hernandez, Barbara Chapman, Wenguang Chen and Weimin Zheng, "OpenUH: An Optimizing, Portable OpenMP Compiler", 12th Workshop on Compilers for Parallel Computers, A Coruna, Spain, Jan. 9-11, 2006

