/* This header file contains the function prototypes for * concurrency. */ #ifndef _CONCURRENCY_ #define _CONCURRENCY_ /* includes civlc.cvh because this library references $scope */ #include #include #pragma CIVL ACSL /* ********************************* Types ********************************* */ /* A data type representing a global barrier which must be operated by local * barriers. */ typedef struct _gbarrier * $gbarrier; /* A data type representing a global barrier which used for * operating global barriers. The local barrier type has * a handle of a global barrier. */ typedef struct _barrier * $barrier; /* ******************************* Functions ******************************* */ /* Creates a new barrier object and returns a handle to it. * The barrier has the specified size. * The new object will be allocated in the given scope. */ /*@ depends_on \nothing; @ assigns \nothing; @ reads \nothing; @ */ $atomic_f $gbarrier $gbarrier_create($scope scope, int size); /* Destroys the gbarrier */ /*@ depends_on \access(gbarrier); @ reads \nothing; @ assigns gbarrier; @ */ $atomic_f void $gbarrier_destroy($gbarrier gbarrier); int $get_nprocs($gbarrier gbarrier); /* Creates a new local barrier object and returns a handle to it. * The new barrier will be affiliated with the specified global * barrier. This local barrier handle will be used as an * argument in most barrier functions. The place must be in * [0,size-1] and specifies the place in the global barrier * that will be occupied by the local barrier. * Only one call to $barrier_create may occur for each barrier-place pair. * The new object will be allocated in the given scope. */ /*@ depends_on \nothing; @ assigns gbarrier; @ reads gbarrier; @ */ $atomic_f $barrier $barrier_create($scope scope, $gbarrier gbarrier, int place); /* Destroys the barrier. */ /*@ depends_on \access(barrier); @ assigns barrier; @ reads \nothing; @ */ $atomic_f void $barrier_destroy($barrier barrier); /* Calls the barrier associated with this local barrier object.*/ void $barrier_call($barrier barrier); /* Calls the barrier from within an atomic section: this will yield at the point where process is waiting to exit barrier. Great POR performance is not guaranteed --- it is better to rewrite your code so that barriers are called outside of atomic sections. */ void $barrier_call_yield($barrier barrier); void $barrier_call_subset($barrier barrier, int nprocs); void $barrier_call_execute($barrier barrier, void foo(void)); #endif