libxmp/libxmpf in Omni Compiler  1.3.4
xmp_post_wait_tca.c File Reference
#include <stdlib.h>
#include <pthread.h>
#include "xmp_internal.h"
#include <time.h>
#include <sys/time.h>
Include dependency graph for xmp_post_wait_tca.c:

Data Structures

struct  _XMP_postreq_info
 
struct  _XMP_postreq
 

Typedefs

typedef struct _XMP_postreq_info _XMP_postreq_info_t
 
typedef struct _XMP_postreq _XMP_postreq_t
 

Functions

void _xmp_tca_post_wait_initialize ()
 Initialize environment for post/wait directives. More...
 
void _xmp_tca_postreq (const int node, const int tag)
 
void _xmp_tca_post (const int node, const int tag)
 Post operation. More...
 
void _xmp_tca_wait_noargs ()
 Wait operation without node-ref and tag. More...
 
void _xmp_tca_wait_node (const int node)
 Wait operation with node-ref. More...
 
double getElapsedTime_ (struct timespec *begin, struct timespec *end)
 
void _xmp_tca_wait (const int node, const int tag)
 Wait operation with node-ref and tag. More...
 

Typedef Documentation

◆ _XMP_postreq_info_t

◆ _XMP_postreq_t

typedef struct _XMP_postreq _XMP_postreq_t

Function Documentation

◆ _xmp_tca_post()

void _xmp_tca_post ( const int  node,
const int  tag 
)

Post operation.

Parameters
[in]nodenode number
[in]tagtag
157 {
158  if(node == _XMP_world_rank){
159  do_post(_XMP_world_rank, tag);
160  } else{
161  _XMP_tca_comm_send(node, _XMP_TCA_POSTREQ_TAG, tag);
162  }
163 }
Here is the caller graph for this function:

◆ _xmp_tca_post_wait_initialize()

void _xmp_tca_post_wait_initialize ( )

Initialize environment for post/wait directives.

31 {
32  _postreq.num = 0;
33  _postreq.max_size = _XMP_POSTREQ_TABLE_INITIAL_SIZE;
34  _postreq.table = malloc(sizeof(_XMP_postreq_info_t) * _postreq.max_size);
35  pthread_mutex_init(&_postreq.lock, NULL);
36  pthread_cond_init(&_postreq.added, NULL);
37 
38  _postreq.table[0].node = 0;
39  _postreq.table[_postreq.max_size-1].node=0;
40 }
Here is the caller graph for this function:

◆ _xmp_tca_postreq()

void _xmp_tca_postreq ( const int  node,
const int  tag 
)
146 {
147  do_post(node, tag);
148 }

◆ _xmp_tca_wait()

void _xmp_tca_wait ( const int  node,
const int  tag 
)

Wait operation with node-ref and tag.

Parameters
[in]nodenode number
[in]tagtag
238 {
239  pthread_mutex_lock(&_postreq.lock);
240 
241  if(_postreq.num == 0){
242  pthread_cond_wait(&_postreq.added, &_postreq.lock);
243  }
244 
245  if(remove_request(node, tag)){
246  pthread_mutex_unlock(&_postreq.lock);
247  return;
248  }
249 
250  while(1){
251  pthread_cond_wait(&_postreq.added, &_postreq.lock);
252 
253  if(remove_request(node, tag)){
254  pthread_mutex_unlock(&_postreq.lock);
255  return;
256  }
257  }
258 
259  /*
260  pthread_mutex_lock(&__lock);
261  while(__reqnum == 0){
262  pthread_cond_wait(&__notempty, &__lock);
263  }
264  --__reqnum;
265  pthread_mutex_unlock(&__lock);
266  return;
267  */
268 
269  /*
270  volatile int *reqnum_p = &__reqnum;
271  while(1){
272  pthread_mutex_lock(&__lock);
273  if(*reqnum_p > 0){
274  --*reqnum_p;
275  pthread_mutex_unlock(&__lock);
276  break;
277  }else{
278  pthread_mutex_unlock(&__lock);
279  }
280  }
281  return ;
282  */
283  /* //fprintf(stderr, "_xmp_tca_wait(%d, %d)\n", node, tag); */
284  /* clock_gettime(CLOCK_MONOTONIC, &begin_ts_2); */
285  /* //fprintf(stderr, "_xmp_tca_wait(%d,%d)\n", node, tag); */
286  /* volatile int *num_p = &(_postreq.num); */
287  /* while(*num_p < 1){ */
288  /* _mm_pause(); */
289  /* } */
290  /* while(remove_request(node, tag) == false){ */
291  /* //_mm_pause(); */
292  /* } */
293  /* clock_gettime(CLOCK_MONOTONIC, &end_ts_2); */
294  /* // if(_XMP_world_rank==1) fprintf(stderr, "wait time=%f\n", getElapsedTime_(&begin_ts_2, &end_ts_2)*1000*1000); */
295  /* //if(_XMP_world_rank==1) fprintf(stderr, "between time=%f, %f\n", getElapsedTime_(&begin_ts_2, &begin_ts)*1000*1000, getElapsedTime_(&end_ts, &end_ts_2)*1000*1000); */
296 }
Here is the caller graph for this function:

◆ _xmp_tca_wait_noargs()

void _xmp_tca_wait_noargs ( )

Wait operation without node-ref and tag.

169 {
170  /* while(remove_request_noargs() == false){ */
171  /* continue; */
172  /* } */
173 
174  pthread_mutex_lock(&_postreq.lock);
175 
176  if(_postreq.num == 0){
177  pthread_cond_wait(&_postreq.added, &_postreq.lock);
178  }
179 
180  if(remove_request_noargs()){
181  pthread_mutex_unlock(&_postreq.lock);
182  return;
183  }
184 
185  while(1){
186  pthread_cond_wait(&_postreq.added, &_postreq.lock);
187 
188  if(remove_request_noargs()){
189  pthread_mutex_unlock(&_postreq.lock);
190  return;
191  }
192  }
193 }
Here is the caller graph for this function:

◆ _xmp_tca_wait_node()

void _xmp_tca_wait_node ( const int  node)

Wait operation with node-ref.

Parameters
[in]nodenode number
201 {
202  /* while(remove_request_node(node) == false){ */
203  /* continue; */
204  /* } */
205 
206  pthread_mutex_lock(&_postreq.lock);
207 
208  if(_postreq.num == 0){
209  pthread_cond_wait(&_postreq.added, &_postreq.lock);
210  }
211 
212  if(remove_request_node(node)){
213  pthread_mutex_unlock(&_postreq.lock);
214  return;
215  }
216 
217  while(1){
218  pthread_cond_wait(&_postreq.added, &_postreq.lock);
219 
220  if(remove_request_node(node)){
221  pthread_mutex_unlock(&_postreq.lock);
222  return;
223  }
224  }
225 }
Here is the caller graph for this function:

◆ getElapsedTime_()

double getElapsedTime_ ( struct timespec *  begin,
struct timespec *  end 
)
352  {
353  return (end->tv_sec - begin->tv_sec) + (end->tv_nsec - begin->tv_nsec) * 1e-9;
354 }
_XMP_postreq::num
int num
How many post requests are in table.
Definition: xmp_post_wait_fjrdma.c:19
_XMP_postreq::max_size
int max_size
Max size of table.
Definition: xmp_post_wait_fjrdma.c:20
_XMP_postreq_info
Definition: xmp_post_wait_fjrdma.c:12
_XMP_postreq::lock
pthread_mutex_t lock
Definition: xmp_post_wait_tca.c:16
_XMP_world_rank
int _XMP_world_rank
Definition: xmp_world.c:9
_XMP_postreq::table
_XMP_postreq_info_t * table
Table for post requests.
Definition: xmp_post_wait_fjrdma.c:18
_XMP_postreq::added
pthread_cond_t added
Definition: xmp_post_wait_tca.c:17
_XMP_postreq_info::node
int node
Definition: xmp_post_wait_fjrdma.c:13
_XMP_tca_comm_send
void _XMP_tca_comm_send(const int rank, const int tag, const int data)
Definition: xmp_onesided_tca.c:246