• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ shmem_n_pes函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中shmem_n_pes函数的典型用法代码示例。如果您正苦于以下问题:C++ shmem_n_pes函数的具体用法?C++ shmem_n_pes怎么用?C++ shmem_n_pes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了shmem_n_pes函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: roundrobin

void* roundrobin(void* tparam) {
    ptrdiff_t tid = (ptrdiff_t)tparam;
    int offset = tid*N_ELEMS;
    /* fprintf(stderr,"Starting thread %lu with offset %d\n",tid,offset); */

    int nextpe = (shmem_my_pe()+1)%shmem_n_pes();
    int prevpe = (shmem_my_pe()-1 + shmem_n_pes())%shmem_n_pes();
    shmem_long_put(target+offset, source+offset, N_ELEMS, nextpe);

    /* fprintf(stderr,"Thread %lu done first put\n",tid); */
    pthread_barrier_wait(&fencebar);
    if(tid == 0) shmem_barrier_all();
    pthread_barrier_wait(&fencebar);

    shmem_long_get(source+offset, target+offset, N_ELEMS, prevpe);

    /* fprintf(stderr,"Thread %lu done first get\n",tid); */
    pthread_barrier_wait(&fencebar);
    if(tid == 0) shmem_barrier_all();
    pthread_barrier_wait(&fencebar);

    shmem_long_get(target+offset, source+offset, N_ELEMS, nextpe);

    /* fprintf(stderr,"Thread %lu done second get\n",tid); */
    pthread_barrier_wait(&fencebar);
    if(tid == 0) shmem_barrier_all();
    pthread_barrier_wait(&fencebar);
    /* fprintf(stderr,"Done thread %lu\n",tid); */

    return 0;
}
开发者ID:jpdoyle,项目名称:SOS,代码行数:31,代码来源:threading.c


示例2: main

int
main (int argc, char **argv)
{
  int npes;
  int me;
  int *ip;

  start_pes (0);
  npes = shmem_n_pes ();
  me = shmem_my_pe ();

  /* fire off allocation */
  ip = shmalloc_nb (sizeof (*ip));

  printf ("PE %d / %d does some other work in the middle of shmalloc_nb\n", me, npes);

  /* now wait for all PEs to be ready */
  shmem_barrier_all ();

  if (me == 0)
    {
      /* PE 0 writes number of PEs to top PE */
      shmem_int_p (ip, npes, npes - 1);
    }

  shmem_barrier_all ();

  printf ("PE %d  / %d says \"ip\" = %d\n", me, npes, *ip);

  shfree_nb (ip);

  printf ("PE %d / %d does some other work in the middle of shfree_nb\n", me, npes);

  return 0;
}
开发者ID:openshmem-org,项目名称:sc14-tutorial,代码行数:35,代码来源:mem_nb.c


示例3: main

int
main()
{
    int me, npes;

    setbuf(stdout, NULL);

    shmem_init();
    me = shmem_my_pe();
    npes = shmem_n_pes();

    if (me == 0) {
        int i;
        for (i = 1; i < npes; i += 1) {
            printf("From %d: PE %d is ", me, i);
            printf("%s", shmem_pe_accessible(i) ? "" : "NOT ");
            printf("accessible\n");
        }
    }
    else {
        ;
    }

    shmem_finalize();

    return 0;
}
开发者ID:openshmem-org,项目名称:openshmem-examples,代码行数:27,代码来源:ping.c


示例4: main

int main(int argc, char *argv[])
{
  shmem_init();
  input_file = argv[1];
  mype = shmem_my_pe();
  NumProcs = shmem_n_pes();
  shmemx_am_attach(hid_BESTPATH, &handler_master_bestpath);
  shmemx_am_attach(hid_SUBSCRIBE, &handler_master_subscribe);
  shmemx_am_attach(hid_PUTPATH, &handler_master_putpath);
  shmemx_am_mutex_init(&lock_shortestlen);
  shmemx_am_mutex_init(&lock_queue);
  shmemx_am_mutex_init(&lock_workers_stack);

  if (NumProcs<2) {
    printf("At least 2 processes are required\n");
    exit(-1);
  }  

  
  // Initialize distance matrix. Ususally done by one process 
  // and bcast, or initialized from a file in a shared file system.
  Fill_Dist();  // process 0 read the data and broadcast it to the others

  if (mype==0) 
    Master();
  else
    Worker();
  
  //TODO
//  shmemx_am_detach(hid_BESTPATH);
//  shmemx_am_detach(hid_SUBSCRIBE);
//  shmemx_am_detach(hid_PUTPATH);
  shmem_finalize();
  return 0;
}
开发者ID:sidjana,项目名称:traveling_salesman_shmem_am,代码行数:35,代码来源:tsp.cpp


示例5: main

int main(int argc, char **argv)
{
  const long int ITER_CNT = 100;
  const long int MAX_MSG_SIZE = 1048576;
  int* source_addr;
  int peer;
  long int i=0,j=0, buff_size; 
  long long int start_time, stop_time, res;
  double time;

  shmem_init();

  int pe_id = shmem_my_pe();
  source_addr = (int*) malloc(MAX_MSG_SIZE);

  if(pe_id == 1) {
      if(shmem_n_pes()!=4)
      	fprintf(stderr,"Num PEs should be ==4");
      printf("#Message Cnt;Time(s);MR(msgs/sec)\n");
  }

  if (pe_id==1)
	  peer = 3;
  else if(pe_id==3)
	  peer = 1;
  get_rtc_res_(&res);

  for (i = 0; i < SHMEM_BARRIER_SYNC_SIZE; i += 1){
          pSync[i] = SHMEM_SYNC_VALUE;
  }

  /* Collective operation: Implicit barrier on return from attach */
  shmemx_am_attach(HANDLER_ID_REQ, &sample_req_handler);
  shmem_barrier_all();
  if(pe_id == 1 || pe_id == 3) {

  	for(buff_size=1; buff_size<=MAX_MSG_SIZE; buff_size*=2) {
  	    shmem_barrier(1,1,2,pSync);
  	    get_rtc_(&start_time);
  	    for(j=1;j<=ITER_CNT;j++) {
  	        if(pe_id == 1) {
  	    	    shmemx_am_request(peer, HANDLER_ID_REQ, source_addr, buff_size);
  	            shmemx_am_quiet();
  	        }
  	    }
  	    shmem_barrier(1,1,2,pSync);
  	    get_rtc_(&stop_time);
  	    time = (stop_time - start_time)*1.0/(double)res/ITER_CNT;
  	    if(pe_id == 1) {
  	   	 printf("%20ld;%20.12f;%20.12f\n", 
  	                buff_size, time, (double)buff_size/time);
  	    }
  	    fflush(stdout);
  	}
  }

  shmem_barrier_all();
  shmem_finalize();

}
开发者ID:openshmem-org,项目名称:openshmem-am-testsuite,代码行数:60,代码来源:bw_unidirectional_1sided.c


示例6: main

int
main ()
{
    int i;
    int me;
    int npes;

    for (i = 0; i < _SHMEM_REDUCE_SYNC_SIZE; i += 1) {
        pSync[i] = _SHMEM_SYNC_VALUE;
    }

    shmem_init ();
    me = shmem_my_pe ();
    npes = shmem_n_pes ();

    src = me + 1;
    shmem_barrier_all ();

    shmem_int_or_to_all (&dst, &src, 1, 0, 0, npes, pWrk, pSync);

    printf ("%d/%d   dst = %d\n", me, npes, dst);

    shmem_finalize ();

    return 0;
}
开发者ID:kseager,项目名称:openshmem-examples,代码行数:26,代码来源:reduce-or.c


示例7: main

int main(int argc, char* argv[]) {
    int verbose = 0;
    if(argc > 1) {
        verbose = !strcmp("-v",argv[1]);
    }

    int errors = 0;

    int me, myshmem_n_pes;
    shmem_init();
    myshmem_n_pes = shmem_n_pes();
    me = shmem_my_pe();

    srand(1+me);

    int nextpe = (me+1)%myshmem_n_pes;

#define RUN_TEST(TYPENAME,TYPE) do { \
        errors += (TYPENAME##_rmaTest(nextpe,verbose)); \
    } while(0)

    SHMEM_DECLARE_FOR_RMA(RUN_TEST);

    shmem_finalize();

    return errors;
}
开发者ID:psonawane27,项目名称:SOS,代码行数:27,代码来源:rma_coverage.c


示例8: initializeCommunication

void initializeCommunication(LSMSCommunication &comm)
{
  //MPI_Init(NULL,NULL);
  //comm.comm=MPI_COMM_WORLD;
  //MPI_Comm_rank(comm.comm, &comm.rank);
  //MPI_Comm_size(comm.comm, &comm.size);
  
  int i;
  shmem_init();
  allocate_symm_buffers();
  comm.comm.rank = shmem_my_pe();
  comm.comm.size = shmem_n_pes();
  comm.comm.start_pe = 0;
  comm.comm.logPE_stride = 0;
  sync_send_flag=(int*)shmalloc(comm.comm.size*sizeof(int));
  sync_recv_flag=(int*)shmalloc(comm.comm.size*sizeof(int));
  memset(sync_send_flag,0,comm.comm.size*sizeof(int));
  memset(sync_recv_flag,0,comm.comm.size*sizeof(int));


  for (i=0;i<comm.comm.size;i++)
  {
    sync_send_flag[i]=0;
    sync_recv_flag[i]=0;
  }

  shmem_barrier_all();

  for (i = 0; i < _SHMEM_BCAST_SYNC_SIZE; i += 1)
  {
        pSync1[i] = _SHMEM_SYNC_VALUE;
        pSync2[i] = _SHMEM_SYNC_VALUE;
  }

}
开发者ID:sidjana,项目名称:lsms-shmem,代码行数:35,代码来源:LSMSCommunication.cpp


示例9: main

int
main ()
{
    int i;

    for (i = 0; i < _SHMEM_REDUCE_SYNC_SIZE; i += 1) {
        pSync[i] = _SHMEM_SYNC_VALUE;
    }

    shmem_init ();

    for (i = 0; i < N; i += 1) {
        src[i] = shmem_my_pe () + i;
    }
    shmem_barrier_all ();

    shmem_long_max_to_all (dst, src, 3, 0, 0, 4, pWrk, pSync);

    printf ("%d/%d   dst =", shmem_my_pe (), shmem_n_pes ());
    for (i = 0; i < N; i += 1) {
        printf (" %ld", dst[i]);
    }
    printf ("\n");

    shmem_finalize ();

    return 0;
}
开发者ID:kseager,项目名称:openshmem-examples,代码行数:28,代码来源:reduce-max.c


示例10: main

int main(){
    int me, npes;
    start_pes(0);
    me = shmem_my_pe();
    npes = shmem_n_pes();
    for (i = 0; i < _SHMEM_REDUCE_SYNC_SIZE; i += 1)
	{
	    pSync[i] = _SHMEM_SYNC_VALUE;
	}
    x = 42; 
    y = 0;
    if(me==0){
	shmem_barrier_all();
	temp = x+y;
    }
    else { 
	shmem_barrier_all();
	if(me==1){
	    old = shmem_int_finc (&y, 0);
	    shmem_int_sum_to_all(&y,&x,1,1,0,npes-1,pWrk,pSync);
	    x= x+10;
	    shmem_int_get(&y,&y,1,0);
	}
	else{
	    shmem_int_sum_to_all(&y,&x, 1,1,0,npes-1,pWrk,pSync);
	    x=y*0.23;
	}
    }
    shmem_barrier_all();
    if (me == 0) {
	printf("value in temp is %d (should be 42)\n", temp);
    }
  
    return 0;
}
开发者ID:openshmem-org,项目名称:osa-testcodes,代码行数:35,代码来源:test-barrier-matching2.c


示例11: main

int  main(void)
{
    int i;
    int my_pe, num_pes;

    for (i = 0; i < SHMEM_BCAST_SYNC_SIZE; i += 1) {
        pSync[i] = _SHMEM_SYNC_VALUE;
    }

    shmem_init();

    my_pe = shmem_my_pe();
    num_pes = shmem_n_pes();

    for (i = 0; i < N; i += 1) {
        src[i] = my_pe + i;
    }

    shmem_barrier_all();

    shmem_long_max_to_all(dst, src, N, 0, 0, num_pes, pWrk, pSync);

    printf("%d/%d dst =", my_pe, num_pes);

    for (i = 0; i < N; i+= 1) {
        printf(" %ld", dst[i]);
    }

    printf("\n");
    shmem_finalize();

    return 0;
}
开发者ID:ICLDisco,项目名称:ompi,代码行数:33,代码来源:oshmem_max_reduction.c


示例12: main

int
main(void)
{
    int i;

    shmem_init();
    npes = shmem_n_pes();
    me = shmem_my_pe();

    for (i = 0; i < DST_SIZE; i++) {
        dst[i] = -1;
    }

    for (i = 0; i < SHMEM_COLLECT_SYNC_SIZE; i += 1) {
        pSync[i] = SHMEM_SYNC_VALUE;
    }

    shmem_barrier_all();

    shmem_fcollect64(dst, src, 2, 0, 0, npes, pSync);

    shmem_barrier_all();

    show_dst("AFTER");

    shmem_finalize();

    return 0;
}
开发者ID:openshmem-org,项目名称:openshmem-examples,代码行数:29,代码来源:fcollect64.c


示例13: main

int
main (void)
{
  int i;

  start_pes (0);
  npes = shmem_n_pes ();
  me = shmem_my_pe ();

  for (i = 0; i < DST_SIZE; i++)
    {
      dst[i] = -1;
    }

  for (i = 0; i < _SHMEM_BCAST_SYNC_SIZE; i += 1)
    {
      pSync[i] = _SHMEM_SYNC_VALUE;
    }

  shmem_barrier_all ();

  shmem_collect64 (dst, src, me + 1, 0, 0, 4, pSync);

  show_dst ("AFTER");

  return 0;
}
开发者ID:openshmem-org,项目名称:sc14-tutorial,代码行数:27,代码来源:collect64.c


示例14: main

int main()
{
    start_pes(0);
    
    me = shmem_my_pe();
    npes = shmem_n_pes();
    
    shmem_barrier_all();
  
    if(me%2==0){
	a = 42;
	shmem_barrier_all();	
    }	
    else{	
	a = 0;
	//shmem_barrier_all();	
    }	
  
    shmem_barrier_all();

    if (me == 0) {
	printf("value in a is %d (should be 42)\n", a);
    }

    return 0;
}
开发者ID:openshmem-org,项目名称:osa-testcodes,代码行数:26,代码来源:test-barrier-matching1.c


示例15: main

int
main (int argc, char **argv)
{
    int i;
    int nextpe;
    int me, npes;
    long src[N];
    long *dest;
    shmemx_request_handle_t handle;

    shmem_init ();
    me = shmem_my_pe ();
    npes = shmem_n_pes ();

    for (i = 0; i < N; i += 1) {
        src[i] = (long) me;
    }

    dest = (long *) shmem_malloc (N * sizeof (*dest));

    nextpe = (me + 1) % npes;

    shmemx_long_put_nb (dest, src, N, nextpe, &handle);

    shmemx_wait_req (handle);

    shmem_barrier_all ();

    shmem_free (dest);

    shmem_finalize ();

    return 0;
}
开发者ID:openshmem-org,项目名称:openshmem-examples,代码行数:34,代码来源:arrput_nb.c


示例16: main

int
main (int argc, char **argv)
{
    int dest;
    int src;
    int me, npes;

    shmem_init ();

    me = shmem_my_pe ();
    npes = shmem_n_pes ();

    src = 42;

    shmem_barrier_all ();

    if (me == 0) {
        shmem_int_put (&dest, &src, 1, 1);
    }

    shmem_barrier_all ();

    shmem_finalize ();

    return 0;
}
开发者ID:openshmem-org,项目名称:osa-testcodes,代码行数:26,代码来源:badput.c


示例17: main

int
main(int argc, char* argv[])
{
    int i, j, num_pes;
    int failed = 0;

    shmem_init();

    if (shmem_my_pe() == 0) {
        num_pes=shmem_n_pes();

        for(j = 0; j < num_pes; j++) {
            memset(target, 0, sizeof(long) * 10);
            shmem_long_get_nbi(target, source, 10, j);
            shmem_quiet();

            for (i = 0; i < 10; i++) {
                if (source[i] != target[i]) {
                    fprintf(stderr,"[%d] get_nbi from PE %d: target[%d] = %ld, expected %ld\n",
                            shmem_my_pe(), j, i, target[i], source[i]);
                    failed = 1;
                }
            }

            if (failed)
                shmem_global_exit(1);
        }
    }

    shmem_finalize();

    return 0;
}
开发者ID:caomw,项目名称:SOS,代码行数:33,代码来源:get_nbi.c


示例18: Setup

void Setup(ArgStruct *p)
{
   int npes;

   start_pes(2);

   if((npes=shmem_n_pes())!=2) {

      printf("Error Message: Run with npes set to 2\n");
      exit(1);
   }

   p->prot.flag=(int *) shmalloc(sizeof(int));
   pTime = (double *) shmalloc(sizeof(double));
   pNrepeat = (int *) shmalloc(sizeof(int));

   p->tr = p->rcv = 0;

   if((p->prot.ipe=_my_pe()) == 0) {
      p->tr=1;
      p->prot.nbor=1;
      *p->prot.flag=1;

   } else {

      p->rcv=1;
      p->prot.nbor=0;
      *p->prot.flag=0;
   }
}
开发者ID:carriercomm,项目名称:ix,代码行数:30,代码来源:shmem.c


示例19: init_it

void init_it(int  *argc, char ***argv) {
    //mpi_err = MPI_Init(argc,argv);
    //mpi_err = MPI_Comm_size( MPI_COMM_WORLD, &numnodes );
    //mpi_err = MPI_Comm_rank(MPI_COMM_WORLD, &myid);
    start_pes(0);
    numnodes = shmem_n_pes();
    myid = shmem_my_pe();
}
开发者ID:openshmem-org,项目名称:sc14-tutorial,代码行数:8,代码来源:shmem_all.c


示例20: main

int main(void)
{
    start_pes(0);
    printf("I am %d of %d. \n",
           shmem_my_pe(), shmem_n_pes() );

    return 0;
}
开发者ID:jeffhammond,项目名称:oshmpi,代码行数:8,代码来源:test_start.c



注:本文中的shmem_n_pes函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ shmget函数代码示例发布时间:2022-05-30
下一篇:
C++ shmem_my_pe函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap