Beispiel #1
0
void entrypoint(void *arg) {

    int n_asyncs = 5;
    int *count = (int *)malloc(sizeof(int));
    assert(count);
    *count = 0;

    hclib_start_finish();
    int i;
    hclib_future_t *prev = NULL;
    for (i = 0; i < n_asyncs; i++) {
        if (prev) {
            hclib_future_t **future_list = (hclib_future_t **)malloc(
                    2 * sizeof(hclib_future_t *));
            assert(future_list);
            future_list[0] = prev;
            future_list[1] = NULL;
            prev = hclib_async_future(async_fct, count, future_list, NULL,
                    NULL, NO_PROP);
        } else {
            prev = hclib_async_future(async_fct, count, NULL, NULL, NULL,
                    NO_PROP);
        }
    }
    hclib_end_finish();

    assert(*count == n_asyncs);
}
Beispiel #2
0
static void _hclib_finalize_ctx(LiteCtx *ctx) {
    hclib_end_finish();
    // Signal shutdown to all worker threads
    hclib_signal_join(hc_context->nworkers);
    // Jump back to the system thread context for this worker
    ctx_swap(ctx, CURRENT_WS_INTERNAL->root_ctx, __func__);
    HASSERT(0); // Should never return here
}
Beispiel #3
0
static void pragma147_omp_task_hclib_async(void *____arg) {
    pragma147_omp_task *ctx = (pragma147_omp_task *)____arg;
    hclib_start_finish();
{
              par_sort((*(ctx->buf_ptr)));
          } ;     ; hclib_end_finish();

    free(____arg);
}
Beispiel #4
0
static void main_entrypoint(void *____arg) {
    main_entrypoint_ctx *ctx = (main_entrypoint_ctx *)____arg;
    int n; n = ctx->n;
{
hclib_start_finish(); {
                par_res = fib(n);
            } ; hclib_end_finish(); 
    } ;     free(____arg);
}
Beispiel #5
0
void shmem_hclib_end_finish() {
  hclib_end_finish();
  /*
   * In HC-OpenSHMEM, there is no start_finish equivalent call. 
   * The end_finish is called everytime user will call shmem_fence/shmem_barrier etc.
   * Once the end_finish (implicitely) is called from HC-OpenSHMEM, 
   * a new start_finish scope is started to pair with
   * the hclib_end_finish implicitely called at the end of user_main.
   */
  hclib_start_finish();
}
Beispiel #6
0
void entrypoint(void *arg) {
    volatile int * indices = (int *) malloc(sizeof(int)*NB_ASYNC);
    ran = (int *) malloc(sizeof(int)*NB_ASYNC);
    init_ran(ran, NB_ASYNC);

    hclib_start_finish();

    spawn_async(indices, 0);

    hclib_end_finish();

    printf("Call Finalize\n");
}
Beispiel #7
0
void spawn_async(volatile int * indices, int i) {
    if (i < NB_ASYNC) {
        hclib_start_finish();

        indices[i] = i;
        hclib_async(async_fct, (void*) (indices+i), NO_FUTURE, NO_PHASER,
                ANY_PLACE, NO_PROP);
        spawn_async(indices, i+1);

        hclib_end_finish();
        assert_done(i, i+1);
    }
}
Beispiel #8
0
// this would go away once hclib fibre support is fixed for communication worker
void temporary_wrapper(void* entrypoint) {
  /*
   * In HC-OpenSHMEM, there is no start_finish equivalent call.
   * The end_finish is called everytime user will call shmem_fence/shmem_barrier etc.
   * Once the end_finish (implicitely) is called from HC-OpenSHMEM,
   * a new start_finish scope is started to pair with
   * the hclib_end_finish implicitely called at the end of user_main.
   */
  hclib_start_finish();
  asyncFct_t funcPtr = (asyncFct_t) entrypoint;
  funcPtr(NULL);
  hclib_end_finish();
}
Beispiel #9
0
void par_sort(void* arg) {
  sort_data_t *in = (sort_data_t*) arg;
  TYPE* data = in->buffer;
  int left = in->left; 
  int right = in->right;

  if (right - left + 1 > HC_GRANULARITY) {
    int index = partition(data, left, right);
hclib_start_finish(); {
        if (left < index - 1) {
          sort_data_t* buf = (sort_data_t*) malloc(sizeof(sort_data_t)); 
          buf->buffer = data;
          buf->left = left;
          buf->right = index - 1; 
 { 
pragma137_omp_task *new_ctx = (pragma137_omp_task *)malloc(sizeof(pragma137_omp_task));
new_ctx->buf_ptr = &(buf);
new_ctx->index_ptr = &(index);
new_ctx->in_ptr = &(in);
new_ctx->data_ptr = &(data);
new_ctx->left_ptr = &(left);
new_ctx->right_ptr = &(right);
new_ctx->arg_ptr = &(arg);
hclib_async(pragma137_omp_task_hclib_async, new_ctx, NO_FUTURE, ANY_PLACE);
 } 
        }
        if (index < right) {
          sort_data_t* buf = (sort_data_t*) malloc(sizeof(sort_data_t)); 
          buf->buffer = data;
          buf->left = index;
          buf->right = right; 
 { 
pragma147_omp_task *new_ctx = (pragma147_omp_task *)malloc(sizeof(pragma147_omp_task));
new_ctx->buf_ptr = &(buf);
new_ctx->index_ptr = &(index);
new_ctx->in_ptr = &(in);
new_ctx->data_ptr = &(data);
new_ctx->left_ptr = &(left);
new_ctx->right_ptr = &(right);
new_ctx->arg_ptr = &(arg);
hclib_async(pragma147_omp_task_hclib_async, new_ctx, NO_FUTURE, ANY_PLACE);
 } 
        }
        } ; hclib_end_finish(); 
  }
  else {
    //  quicksort in C library
    qsort(data+left, right - left + 1, sizeof(TYPE), compare);
  }
  free(arg);
} 
Beispiel #10
0
static void main_entrypoint(void *____arg) {
    main_entrypoint_ctx *ctx = (main_entrypoint_ctx *)____arg;
    int size; size = ctx->size;
{
	total_count=0;

        bots_message("Computing N-Queens algorithm (n=%d) ", size);
hclib_start_finish(); {
			char *a;

			a = (char *)malloc(size * sizeof(char));
			nqueens(size, 0, a, &total_count,0);
		} ; hclib_end_finish(); 
	bots_message(" completed!\n");
    } ;     free(____arg);
}
Beispiel #11
0
void entrypoint(void *arg) {
    int *ran = (int *)arg;
    // This is ok to have these on stack because this
    // code is alive until the end of the program.

    init_ran(ran, H1*H2);
    loop_domain_t loop0 = {0,H1,1,T1};
    loop_domain_t loop1 = {0,H2,1,T2};
    loop_domain_t loop[2] = {loop0, loop1};

    hclib_start_finish();
    hclib_forasync(forasync_fct2, (void*)(ran), NULL, 2, loop,
            FORASYNC_MODE_RECURSIVE);
    hclib_end_finish();

    printf("Call Finalize\n");
}
Beispiel #12
0
void entrypoint(void *arg) {

    int n_asyncs = 5;
    int *count = (int *)malloc(sizeof(int));
    assert(count);
    *count = 0;

    hclib_start_finish();
    int i;
    hclib_future_t *prev = NULL;
    for (i = 0; i < n_asyncs; i++) {
        if (prev) {
            prev = hclib_async_future(async_fct, count, &prev, 1, NULL);
        } else {
            prev = hclib_async_future(async_fct, count, NULL, 0, NULL);
        }
    }
    hclib_end_finish();

    assert(*count == n_asyncs);
}
Beispiel #13
0
long long fib (int n)
{
	long long x, y;
	if (n < 2) return n;

 { 
pragma44_omp_task *new_ctx = (pragma44_omp_task *)malloc(sizeof(pragma44_omp_task));
new_ctx->x_ptr = &(x);
new_ctx->y_ptr = &(y);
new_ctx->n = n;
hclib_async(pragma44_omp_task_hclib_async, new_ctx, NO_FUTURE, ANY_PLACE);
 } ;
 { 
pragma46_omp_task *new_ctx = (pragma46_omp_task *)malloc(sizeof(pragma46_omp_task));
new_ctx->x_ptr = &(x);
new_ctx->y_ptr = &(y);
new_ctx->n = n;
hclib_async(pragma46_omp_task_hclib_async, new_ctx, NO_FUTURE, ANY_PLACE);
 } ;

 hclib_end_finish(); hclib_start_finish(); ;
	return x + y;
} 
Beispiel #14
0
void nqueens(int n, int j, char *a, int *solutions, int depth)
{
	int *csols;
	int i;


	if (n == j) {
		/* good solution, count it */
		*solutions = 1;
		return;
	}


	*solutions = 0;
	csols = (int *)malloc(n*sizeof(int));
	memset(csols,0,n*sizeof(int));

     	/* try each possible position for queen <j> */
	for (i = 0; i < n; i++) {

 { 
pragma126_omp_task *new_ctx = (pragma126_omp_task *)malloc(sizeof(pragma126_omp_task));
new_ctx->csols = csols;
new_ctx->i = i;
new_ctx->n = n;
new_ctx->j = j;
new_ctx->a = a;
new_ctx->solutions = solutions;
new_ctx->depth = depth;
hclib_async(pragma126_omp_task_hclib_async, new_ctx, NO_FUTURE, ANY_PLACE);
 } 
	}

 hclib_end_finish(); hclib_start_finish(); ;
	for ( i = 0; i < n; i++) *solutions += csols[i];
    free(csols);
} 
Beispiel #15
0
void hclib::end_finish() {
    hclib_end_finish();
}
Beispiel #16
0
void sweep (int nx, int ny, double dx, double dy, double *f_,
            int itold, int itnew, double *u_, double *unew_, int block_size)
{
    int it;
    int block_x, block_y;

    if (block_size == 0)
        block_size = nx;

    int max_blocks_x = (nx / block_size);
    int max_blocks_y = (ny / block_size);

hclib_start_finish(); {
        for (it = itold + 1; it <= itnew; it++) {
            // Save the current estimate.
            for (block_x = 0; block_x < max_blocks_x; block_x++) {
                for (block_y = 0; block_y < max_blocks_y; block_y++) {
 { 
pragma26_omp_task *new_ctx = (pragma26_omp_task *)malloc(sizeof(pragma26_omp_task));
new_ctx->it_ptr = &(it);
new_ctx->block_x = block_x;
new_ctx->block_y = block_y;
new_ctx->max_blocks_x_ptr = &(max_blocks_x);
new_ctx->max_blocks_y_ptr = &(max_blocks_y);
new_ctx->nx_ptr = &(nx);
new_ctx->ny_ptr = &(ny);
new_ctx->dx_ptr = &(dx);
new_ctx->dy_ptr = &(dy);
new_ctx->f__ptr = &(f_);
new_ctx->itold_ptr = &(itold);
new_ctx->itnew_ptr = &(itnew);
new_ctx->u__ptr = &(u_);
new_ctx->unew__ptr = &(unew_);
new_ctx->block_size_ptr = &(block_size);
hclib_async(pragma26_omp_task_hclib_async, new_ctx, NO_FUTURE, ANY_PLACE);
 } ;
                }
            }

 hclib_end_finish(); hclib_start_finish(); ;

            // Compute a new estimate.
            for (block_x = 0; block_x < max_blocks_x; block_x++) {
                for (block_y = 0; block_y < max_blocks_y; block_y++) {
 { 
pragma36_omp_task *new_ctx = (pragma36_omp_task *)malloc(sizeof(pragma36_omp_task));
new_ctx->block_x = block_x;
new_ctx->block_y = block_y;
new_ctx->nx_ptr = &(nx);
new_ctx->ny_ptr = &(ny);
new_ctx->dx_ptr = &(dx);
new_ctx->dy_ptr = &(dy);
new_ctx->f__ptr = &(f_);
new_ctx->u__ptr = &(u_);
new_ctx->unew__ptr = &(unew_);
new_ctx->block_size_ptr = &(block_size);
hclib_async(pragma36_omp_task_hclib_async, new_ctx, NO_FUTURE, ANY_PLACE);
 } ;
                }
            }

 hclib_end_finish(); hclib_start_finish(); ;
        }
    } ; hclib_end_finish(); 
} 
Beispiel #17
0
void shmem_workers_finalize() {
  hclib_end_finish();
  hclib_finalize();
}
Beispiel #18
0
void shmem_task_scope_end() {
  hclib_end_finish();
}