libxomp.h

Go to the documentation of this file.
00001 /*  
00002  * A common layer for both gomp and omni runtime library
00003  *  Liao 1/20/2009
00004  *  */
00005 #ifndef LIB_XOMP_H 
00006 #define LIB_XOMP_H
00007 
00008 // Fortran outlined function uses one parameter for each variable to be passed by reference
00009 // We predefine a max number of parameters to be allowed here.
00010 #define MAX_OUTLINED_FUNC_PARAMETER_COUNT 256
00011 #ifdef __cplusplus
00012 extern "C" {
00013 #endif
00014 
00015 #include <stdbool.h>
00016 #include <stdlib.h> // for abort()
00017 
00018 //enum omp_rtl_enum {
00019 //  e_gomp,
00020 //  e_omni,
00021 //  e_last_rtl
00022 //};
00023 //
00024 //extern omp_rtl_enum rtl_type;
00025 
00026 //Runtime library initialization routine
00027 extern void XOMP_init (int argc, char ** argv);
00028 extern void xomp_init (void);
00029 
00030 // Runtime library termination routine
00031 extern void XOMP_terminate (int exitcode);
00032 
00033 // func: pointer to a function which will be run in parallel
00034 // data: pointer to a data segment which will be used as the arguments of func
00035 // ifClauseValue: set to if-clause-expression if if-clause exists, or default is 1. 
00036 // numThreadsSpecified: set to the expression of num_threads clause if the clause exists, or default is 0
00037 extern void XOMP_parallel_start (void (*func) (void *), void *data, unsigned ifClauseValue, unsigned numThreadsSpecified);
00038 extern void XOMP_parallel_end (void);
00039 
00040 /* Initialize sections and return the next section id (starting from 0) to be executed by the current thread */
00041 extern int XOMP_sections_init_next(int section_count); 
00042 
00043 /* Return the next section id (starting from 0) to be executed by the current thread. Return value <0 means no sections left */
00044 extern int XOMP_sections_next(void); 
00045 
00046 /* Called after the current thread is told that all sections are executed. It synchronizes all threads also. */
00047 extern void XOMP_sections_end(void);
00048 
00049 /* Called after the current thread is told that all sections are executed. It does not synchronizes all threads. */
00050 extern void XOMP_sections_end_nowait(void);
00051 
00052 extern void XOMP_task (void (*) (void *), void *, void (*) (void *, void *),
00053                        long, long, bool, unsigned);
00054 extern void XOMP_taskwait (void);
00055 
00056 // scheduler functions, union of runtime library functions
00057 // empty body if not used by one
00058 // scheduler initialization, only meaningful used for OMNI
00059 
00060 // Default loop scheduling, worksharing without any schedule clause, upper bounds are inclusive
00061 // Kick in before all runtime libraries. We use the default loop scheduling from XOMP regardless the runtime chosen.
00062 extern void XOMP_loop_default(int lower, int upper, int stride, long* n_lower, long* n_upper);
00063 
00065 // Non-op for gomp
00066 extern void XOMP_loop_static_init(int lower, int upper, int stride, int chunk_size);
00067 extern void XOMP_loop_dynamic_init(int lower, int upper, int stride, int chunk_size);
00068 extern void XOMP_loop_guided_init(int lower, int upper, int stride, int chunk_size);
00069 extern void XOMP_loop_runtime_init(int lower, int upper, int stride);
00070 
00071 //  ordered case
00072 extern void XOMP_loop_ordered_static_init(int lower, int upper, int stride, int chunk_size);
00073 extern void XOMP_loop_ordered_dynamic_init(int lower, int upper, int stride, int chunk_size);
00074 extern void XOMP_loop_ordered_guided_init(int lower, int upper, int stride, int chunk_size);
00075 extern void XOMP_loop_ordered_runtime_init(int lower, int upper, int stride);
00076 
00077 
00078 // if (start), 
00079 // mostly used because of gomp, omni will just call  XOMP_loop_xxx_next();
00080 // (long start, long end, long incr, long chunk_size,long *istart, long *iend)
00081 //  upper bounds are non-inclusive, 
00082 //  bounds for inclusive loop control will need +/-1 , depending on incremental/decremental cases
00083 extern bool XOMP_loop_static_start (long, long, long, long, long *, long *);
00084 extern bool XOMP_loop_dynamic_start (long, long, long, long, long *, long *);
00085 extern bool XOMP_loop_guided_start (long, long, long, long, long *, long *);
00086 extern bool XOMP_loop_runtime_start (long, long, long, long *, long *);
00087 
00088 extern bool XOMP_loop_ordered_static_start (long, long, long, long, long *, long *);
00089 extern bool XOMP_loop_ordered_dynamic_start (long, long, long, long, long *, long *);
00090 extern bool XOMP_loop_ordered_guided_start (long, long, long, long, long *, long *);
00091 extern bool XOMP_loop_ordered_runtime_start (long, long, long, long *, long *);
00092 
00093 // next
00094 extern bool XOMP_loop_static_next (long *, long *);
00095 extern bool XOMP_loop_dynamic_next (long *, long *);
00096 extern bool XOMP_loop_guided_next (long *, long *);
00097 extern bool XOMP_loop_runtime_next (long *, long *);
00098 
00099 extern bool XOMP_loop_ordered_static_next (long *, long *);
00100 extern bool XOMP_loop_ordered_dynamic_next (long *, long *);
00101 extern bool XOMP_loop_ordered_guided_next (long *, long *);
00102 extern bool XOMP_loop_ordered_runtime_next (long *, long *);
00103 
00104 //--------------end of  loop functions 
00105 
00106 extern void XOMP_barrier (void);
00107 extern void XOMP_critical_start (void** data); 
00108 extern void XOMP_critical_end (void** data);
00109 extern bool XOMP_single(void);
00110 extern bool XOMP_master(void);
00111 
00112 extern void XOMP_atomic_start (void);
00113 extern void XOMP_atomic_end (void);
00114 
00115 extern void XOMP_loop_end (void);
00116 extern void XOMP_loop_end_nowait (void);
00117    // --- end loop functions ---
00118 // flush without variable list
00119 extern void XOMP_flush_all (void);
00120 // omp flush with variable list, flush one by one, given each's start address and size
00121 extern void XOMP_flush_one (char * startAddress, int nbyte);
00122 
00123 
00124 // omp ordered directive
00125 extern void XOMP_ordered_start (void);
00126 extern void XOMP_ordered_end (void);
00127 
00128 #ifdef __cplusplus
00129  }
00130 #endif
00131  
00132 #endif /* LIB_XOMP_H */
00133 
00134 
00135 
00136  

Generated on Sat May 19 00:53:06 2012 for ROSE by  doxygen 1.4.7