Esempio n. 1
0
void async_progress_close(async_progress_t * async_progress)
{
    pami_result_t rc = PAMI_ERROR;
    async_progress_impl_t * async = (async_progress_impl_t *) async_progress;

    /* Close the async progress extension. */
    rc = PAMI_Extension_close (async->extension);
    PAMID_ASSERT(rc==PAMI_SUCCESS,"PAMI_Extension_close - EXT_async_progress");

    return;
}
Esempio n. 2
0
void async_progress_close (async_progress_t * async_progress)
{
  async_progress_impl_t * async = (async_progress_impl_t *) async_progress;

  /*
   * Close the async progress extension.
   */
  pami_result_t result = PAMI_ERROR;
  result = PAMI_Extension_close (async->extension);
  assert (result == PAMI_SUCCESS);

  return;
}
Esempio n. 3
0
void MPIDI_close_pe_extension() {
     extern MPIDI_printenv_t  *mpich_env;
     extern MPIX_stats_t *mpid_statp;
     int rc;
     /* PAMI_Extension_open in pami_init   */
     rc = PAMI_Extension_close (pe_extension);
     if (rc != PAMI_SUCCESS) {
         TRACE_ERR("ERROR close PAMI_Extension failed rc %d", rc);
     }
     if (mpich_env)
         MPIU_Free(mpich_env);
     if (mpid_statp)
         MPIU_Free(mpid_statp);

}
Esempio n. 4
0
int main(int argc, char ** argv)
{
  pami_client_t     client;
  pami_context_t    context;
  pami_result_t     status = PAMI_ERROR;
  
  /* create PAMI client */
  RC( PAMI_Client_create("TEST", &client, NULL, 0) );
  DBG_FPRINTF((stderr,"Client created successfully at 0x%p\n",client));

  /* create PAMI context */
  RC( PAMI_Context_createv(client, NULL, 0, &context, 1) );
  DBG_FPRINTF((stderr,"Context created successfully at 0x%p\n",context));

  /* ------------------------------------------------------------------------ */

  pami_extension_t      extension;
  const char            ext_name[] = "EXT_hfi_extension";
  const char            sym_name[] = "hfi_pkt_counters";
  hfi_pkt_counters_fn   hfi_counters = NULL;
  hfi_pkt_counter_t     pkt_counter;

  /* open PAMI extension */
  RC( PAMI_Extension_open (client, ext_name, &extension) );
  DBG_FPRINTF((stderr,"Open %s successfully.\n", ext_name));

  /* load PAMI extension function */
  hfi_counters = (hfi_pkt_counters_fn) 
      PAMI_Extension_symbol (extension, sym_name);
  if (hfi_counters == (void *)NULL)
  {
    fprintf (stderr, "Error. Failed to load %s function in %s\n",
             sym_name, ext_name); 
    return 1;
  } 
  DBG_FPRINTF((stderr,"Loaded function %s in %s successfully.\n", 
              sym_name, ext_name));

  /* invoke PAMI extension function */
  RC( hfi_counters(context, &pkt_counter) );
  DBG_FPRINTF((stderr,"Function %s invoked successfully.\n", 
              sym_name));
  printf( "Pkt sent =         %lu\n"
          "Pkt sent dropped = %lu\n"
          "Ind pkt sent =     %lu\n"
          "Pkt recv =         %lu\n"
          "Pkt recv dropped = %lu\n"
          "Ind pkt recv =     %lu\n"
          "Imm pkt sent =     %lu\n",
          pkt_counter.total_packets_sent,
          pkt_counter.packets_send_drop,
          pkt_counter.indicate_packet_sent,
          pkt_counter.total_packets_recv,
          pkt_counter.packets_recv_drop,
          pkt_counter.indicate_packet_recv,
          pkt_counter.immediate_packet_sent);

  /* close PAMI extension */
  RC( PAMI_Extension_close (extension) );
  DBG_FPRINTF((stderr,"Close %s successfully.\n", ext_name));

  /* ------------------------------------------------------------------------ */
  /* destroy PAMI context */
  RC( PAMI_Context_destroyv(&context, 1) );
  DBG_FPRINTF((stderr, "PAMI context destroyed successfully\n"));

  /* destroy PAMI client */
  RC( PAMI_Client_destroy(&client) );
  DBG_FPRINTF((stderr, "PAMI client destroyed successfully\n"));

  return 0;
}
Esempio n. 5
0
int main(int argc, char ** argv) {
	pami_client_t client;
	pami_context_t context;
	size_t num_contexts = 1;
	pami_task_t task_id;
	size_t num_tasks;
	pami_geometry_t world_geometry;
	/* Barrier variables */
	size_t num_algorithms[2];
	pami_xfer_type_t barrier_xfer = PAMI_XFER_BARRIER;
	pami_xfer_t barrier;
#if !defined(__bgq__)
	pami_extension_t hfi_extension;
	hfi_remote_update_fn hfi_update;
#endif
	int numAlgorithms = 6;
	pami_xfer_type_t algorithms[] = {PAMI_XFER_BROADCAST, PAMI_XFER_BARRIER,
			PAMI_XFER_SCATTER, PAMI_XFER_ALLTOALL, PAMI_XFER_ALLREDUCE, PAMI_XFER_ALLGATHER};
	const char* algorithmNames[] = {"PAMI_XFER_BROADCAST", "PAMI_XFER_BARRIER",
				"PAMI_XFER_SCATTER", "PAMI_XFER_ALLTOALL", "PAMI_XFER_ALLREDUCE", "PAMI_XFER_ALLGATHER"};

	const char    *name = "X10";
	setenv("MP_MSG_API", name, 1);
	pami_configuration_t config;
	config.name = PAMI_GEOMETRY_OPTIMIZE;
	config.value.intval = 1;

	pami_result_t status = PAMI_Client_create(name, &client, &config, 1);
	if (status != PAMI_SUCCESS)
		error("Unable to initialize PAMI client\n");

	if ((status = PAMI_Context_createv(client, &config, 1, &context, 1)) != PAMI_SUCCESS)
		error("Unable to initialize the PAMI context: %i\n", status);

#if !defined(__bgq__)
	status = PAMI_Extension_open (client, "EXT_hfi_extension", &hfi_extension);
	if (status == PAMI_SUCCESS)
	{
		#ifdef __GNUC__
		__extension__
		#endif
		hfi_update = (hfi_remote_update_fn) PAMI_Extension_symbol(hfi_extension, "hfi_remote_update"); // This may succeed even if HFI is not available
	}
#endif

	status = PAMI_Geometry_world(client, &world_geometry);
		if (status != PAMI_SUCCESS) error("Unable to create the world geometry");

	pami_configuration_t configuration[2];
	configuration[0].name = PAMI_CLIENT_TASK_ID;
	configuration[1].name = PAMI_CLIENT_NUM_TASKS;
	if ((status = PAMI_Client_query(client, configuration, 2)) != PAMI_SUCCESS)
		error("Unable to query the PAMI_CLIENT: %i\n", status);
	int myPlaceId = configuration[0].value.intval;

	if (myPlaceId == 0)
	{
		for (int i = 0; i < numAlgorithms; i++) {
			status = PAMI_Geometry_algorithms_num(world_geometry, algorithms[i], num_algorithms);
			if (status != PAMI_SUCCESS || num_algorithms[0] == 0)
				error("Unable to query the algorithm counts for barrier\n");

			// query what the different algorithms are
			pami_algorithm_t *always_works_alg = (pami_algorithm_t*) alloca(sizeof(pami_algorithm_t)*num_algorithms[0]);
			pami_metadata_t	*always_works_md = (pami_metadata_t*) alloca(sizeof(pami_metadata_t)*num_algorithms[0]);
			pami_algorithm_t *must_query_alg = (pami_algorithm_t*) alloca(sizeof(pami_algorithm_t)*num_algorithms[1]);
			pami_metadata_t	*must_query_md = (pami_metadata_t*) alloca(sizeof(pami_metadata_t)*num_algorithms[1]);
			status = PAMI_Geometry_algorithms_query(world_geometry, algorithms[i], always_works_alg,
					always_works_md, num_algorithms[0], must_query_alg, must_query_md, num_algorithms[1]);
			if (status != PAMI_SUCCESS)
				error("Unable to query the supported algorithm %s for world", algorithmNames[i]);

			// print out
			printf("Collective: %s\n", algorithmNames[i]);
			printf("Always supported: %i algorithms\n", num_algorithms[0]);
			for (int j=0; j<num_algorithms[0]; j++)
				printf("\t%s = %i\n", always_works_md[j].name, j);
			printf("Locally supported: %i algorithms\n", num_algorithms[1]);
			for (int j=0; j<num_algorithms[1]; j++)
				printf("\t%s = %i\n", must_query_md[j].name, num_algorithms[0]+j);
			printf("\n");
		}
	}

#if !defined(__bgq__)
	PAMI_Extension_close (hfi_extension);
#endif

	if ((status = PAMI_Context_destroyv(&context, 1)) != PAMI_SUCCESS)
		fprintf(stderr, "Error closing PAMI context: %i\n", status);
	if ((status = PAMI_Client_destroy(&client)) != PAMI_SUCCESS)
		fprintf(stderr, "Error closing PAMI client: %i\n", status);
	return 0;
}
Esempio n. 6
0
int main(int argc, char ** argv)
{
    pami_client_t         client;
    pami_context_t        context;
    pami_result_t         status = PAMI_ERROR;
    pami_configuration_t  pami_config;
    pami_geometry_t       world_geo;
    size_t                barrier_alg_num[2];
    pami_algorithm_t*     bar_always_works_algo = NULL;
    pami_metadata_t*      bar_always_works_md = NULL;
    pami_algorithm_t*     bar_must_query_algo = NULL;
    pami_metadata_t*      bar_must_query_md   = NULL;
    pami_xfer_t           barrier;
    int                   my_id;
    volatile int          is_fence_done   = 0;
    volatile int          is_barrier_done = 0;

    /* create PAMI client */
    RC( PAMI_Client_create("TEST", &client, NULL, 0) );
    DBG_FPRINTF((stderr,"Client created successfully at 0x%p\n",client));

    /* create PAMI context */
    RC( PAMI_Context_createv(client, NULL, 0, &context, 1) );
    DBG_FPRINTF((stderr,"Context created successfully at 0x%p\n",context));

    /* query my task id */
    bzero(&pami_config, sizeof(pami_configuration_t));
    pami_config.name = PAMI_CLIENT_TASK_ID;
    RC( PAMI_Client_query(client, &pami_config, 1) );
    my_id = pami_config.value.intval;
    DBG_FPRINTF((stderr,"My task id is %d\n", my_id));

    /* get the world geometry */
    RC( PAMI_Geometry_world(client, &world_geo) );
    DBG_FPRINTF((stderr,"World geometry is at 0x%p\n",world_geo));

    /* query number of barrier algorithms */
    RC( PAMI_Geometry_algorithms_num(world_geo, PAMI_XFER_BARRIER, 
                barrier_alg_num) );
    DBG_FPRINTF((stderr,"%d-%d algorithms are available for barrier op\n",
                barrier_alg_num[0], barrier_alg_num[1]));
    if (barrier_alg_num[0] <= 0) {
        fprintf (stderr, "Error. No (%lu) algorithm is available for barrier op\n",
                barrier_alg_num[0]);
        return 1;
    }

    /* query barrier algorithm list */
    bar_always_works_algo =
        (pami_algorithm_t*)malloc(sizeof(pami_algorithm_t)*barrier_alg_num[0]);
    bar_always_works_md =
        (pami_metadata_t*)malloc(sizeof(pami_metadata_t)*barrier_alg_num[0]);
    bar_must_query_algo =
        (pami_algorithm_t*)malloc(sizeof(pami_algorithm_t)*barrier_alg_num[1]);
    bar_must_query_md =
        (pami_metadata_t*)malloc(sizeof(pami_metadata_t)*barrier_alg_num[1]);

    RC( PAMI_Geometry_algorithms_query(world_geo, PAMI_XFER_BARRIER,
                bar_always_works_algo, bar_always_works_md, barrier_alg_num[0],
                bar_must_query_algo, bar_must_query_md, barrier_alg_num[1]) );
    DBG_FPRINTF((stderr,"Algorithm [%s] at 0x%p will be used for barrier op\n",
                bar_always_works_md[0].name, bar_always_works_algo[0]));

    /* begin PAMI fence */
    RC( PAMI_Fence_begin(context) );
    DBG_FPRINTF((stderr,"PAMI fence begins\n"));

    /* ------------------------------------------------------------------------ */

    pami_extension_t          extension;
    const char                ext_name[] = "EXT_hfi_extension";
    const char                sym_name[] = "hfi_remote_update";
    hfi_remote_update_fn      remote_update = NULL;
    hfi_remote_update_info_t  remote_info;
    pami_memregion_t          mem_region;
    size_t                    mem_region_sz = 0;
    unsigned long long        operand = 1234;
    unsigned long long        orig_val = 0;
    int                       offset = (operand)%MAX_TABLE_SZ;

    /* initialize table for remote update operation */
    int i;
    for (i = 0; i < MAX_TABLE_SZ; i ++) {
        table[i] = (unsigned long long) i;
    }
    orig_val = table[offset];

    /* open PAMI extension */
    RC( PAMI_Extension_open (client, ext_name, &extension) );
    DBG_FPRINTF((stderr,"Open %s successfully.\n", ext_name));

    /* load PAMI extension function */
    remote_update = (hfi_remote_update_fn) 
        PAMI_Extension_symbol (extension, sym_name);
    if (remote_update == (void *)NULL)
    {
        fprintf (stderr, "Error. Failed to load %s function in %s\n",
                 sym_name, ext_name); 
        return 1;
    } else {
        DBG_FPRINTF((stderr,"Loaded function %s in %s successfully.\n", 
                    sym_name, ext_name));
    }

    /* create a memory region for remote update operation */
    RC( PAMI_Memregion_create(context, table, 
                MAX_TABLE_SZ*sizeof(unsigned long long),
                &mem_region_sz, &mem_region) );
    DBG_FPRINTF((stderr,"%d-byte PAMI memory region created successfully.\n",
                mem_region_sz));

    /* perform a PAMI barrier */
    is_barrier_done = 0;
    barrier.cb_done = barrier_done;
    barrier.cookie = (void*)&is_barrier_done;
    barrier.algorithm = bar_always_works_algo[0];
    RC( PAMI_Collective(context, &barrier) );
    DBG_FPRINTF((stderr,"PAMI barrier op invoked successfully.\n"));
    while (is_barrier_done == 0)
        PAMI_Context_advance(context, 1000);
    DBG_FPRINTF((stderr,"PAMI barrier op finished successfully.\n"));

    RC( PAMI_Context_lock(context) );

    /* prepare remote update info */
    remote_info.dest = my_id^1;
    remote_info.op = 0;           /* op_add */
    remote_info.atomic_operand = operand;
    remote_info.dest_buf = (unsigned long long)(&(table[offset]));

    /* invoke remote update PAMI extension function */
    RC( remote_update(context, 1, &remote_info) );
    DBG_FPRINTF((stderr,"Function %s invoked successfully.\n", 
                sym_name));

    RC( PAMI_Context_unlock(context) );

    /* perform a PAMI fence */
    is_fence_done = 0;
    RC( PAMI_Fence_all(context, fence_done, (void*)&is_fence_done) );
    DBG_FPRINTF((stderr,"PAMI_Fence_all invoked successfully.\n")); 
    while (is_fence_done == 0)
        PAMI_Context_advance(context, 1000);
    DBG_FPRINTF((stderr,"PAMI_Fence_all finished successfully.\n")); 

    /* perform a PAMI barrier */
    is_barrier_done = 0;
    barrier.cb_done = barrier_done;
    barrier.cookie = (void*)&is_barrier_done;
    barrier.algorithm = bar_always_works_algo[0];
    RC( PAMI_Collective(context, &barrier) );
    DBG_FPRINTF((stderr,"PAMI barrier op invoked successfully.\n"));
    while (is_barrier_done == 0)
        PAMI_Context_advance(context, 1000);
    DBG_FPRINTF((stderr,"PAMI barrier op finished successfully.\n"));

    /* verify data after remote update operation */
    if (table[offset] != orig_val + operand) {
        printf("Data verification at offset %d with operand %lu failed: "
                "[%lu expected with %lu updated]\n",
                offset, operand, orig_val+operand, table[offset]);
    } else {
        printf("Data verification at offset %d with operand %lu passed: "
                "[%lu expected with %lu updated].\n",
                offset, operand, orig_val+operand, table[offset]);
    }

    /* destroy the memory region after remote update operation */
    RC( PAMI_Memregion_destroy(context, &mem_region) );
    DBG_FPRINTF((stderr,"PAMI memory region removed successfully.\n"));

    /* close PAMI extension */
    RC( PAMI_Extension_close (extension) );
    DBG_FPRINTF((stderr,"Close %s successfully.\n", ext_name));

    /* ------------------------------------------------------------------------ */

    /* end PAMI fence */
    RC( PAMI_Fence_end(context) );
    DBG_FPRINTF((stderr,"PAMI fence ends\n"));

    /* destroy PAMI context */
    RC( PAMI_Context_destroyv(&context, 1) );
    DBG_FPRINTF((stderr, "PAMI context destroyed successfully\n"));

    /* destroy PAMI client */
    RC( PAMI_Client_destroy(&client) );
    DBG_FPRINTF((stderr, "PAMI client destroyed successfully\n"));

    return 0;
}
Esempio n. 7
0
int main(int argc, char ** argv)
{
  pami_client_t client;
  pami_context_t context;
  pami_result_t status = PAMI_ERROR;

  status = PAMI_Client_create("TEST", &client, NULL, 0);
  if(status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error. Unable to initialize pami client. result = %d\n", status);
    return 1;
  }

  status = PAMI_Context_createv(client, NULL, 0, &context, 1);
  if(status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error. Unable to create pami context. result = %d\n", status);
    return 1;
  }

  /* ------------------------------------------------------------------------ */

  pami_extension_t extension;
  status = PAMI_Extension_open (client, "EXT_collsel", &extension);
  if(status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error. The \"EXT_collsel\" extension is not implemented. result = %d\n", status);
    return 1;
  }

  //printf("before table init\n");
  pami_extension_collsel_init pamix_collsel_init = 
    (pami_extension_collsel_init) PAMI_Extension_symbol (extension, "Collsel_init_fn");
  if (pamix_collsel_init == (void *)NULL)
  {
    fprintf (stderr, "Error. The \"EXT_collsel\" extension function \"Collsel_init_fn\" is not implemented. result = %d\n", status);
    return 1;
  }
  advisor_t advisor;
  advisor_configuration_t configuration[1];
  status = pamix_collsel_init (client, configuration, 1, &context, 1, &advisor);

  pami_extension_collsel_table_generate pamix_collsel_table_generate = 
    (pami_extension_collsel_table_generate) PAMI_Extension_symbol (extension, "Collsel_table_generate_fn");
  if (pamix_collsel_table_generate == (void *)NULL)
  {
    fprintf (stderr, "Error. The \"EXT_collsel\" extension function \"Collsel_table_generate_fn\" is not implemented. result = %d\n", status);
    return 1;
  }
  advisor_params_t params;
  int i = 0;
  //do a bcast on 16 np 1000 bytes
  params.collectives = (pami_xfer_type_t *)malloc(sizeof(pami_xfer_type_t) * 32);
  params.collectives[i++] = PAMI_XFER_BROADCAST;
  params.collectives[i++] = PAMI_XFER_ALLREDUCE;
  params.collectives[i++] = PAMI_XFER_REDUCE;
  params.collectives[i++] = PAMI_XFER_ALLGATHER;
  params.collectives[i++] = PAMI_XFER_ALLGATHERV;
  params.collectives[i++] = PAMI_XFER_ALLGATHERV_INT;
  params.collectives[i++] = PAMI_XFER_SCATTER;
  params.collectives[i++] = PAMI_XFER_SCATTERV;
  params.collectives[i++] = PAMI_XFER_SCATTERV_INT;
  params.collectives[i++] = PAMI_XFER_GATHER;
  params.collectives[i++] = PAMI_XFER_GATHERV;
  params.collectives[i++] = PAMI_XFER_GATHERV_INT;
  params.collectives[i++] = PAMI_XFER_BARRIER;
  params.collectives[i++] = PAMI_XFER_ALLTOALL;
  params.collectives[i++] = PAMI_XFER_ALLTOALLV;
  params.collectives[i++] = PAMI_XFER_ALLTOALLV_INT;
  params.collectives[i++] = PAMI_XFER_SCAN;
  params.collectives[i++] = PAMI_XFER_REDUCE_SCATTER;
  params.num_collectives = i;

  params.geometry_sizes = (size_t *)malloc(sizeof(size_t));
  params.geometry_sizes[0] =512;
  params.num_geometry_sizes = 1;
  params.message_sizes = (size_t *)malloc(sizeof(size_t));
  //params.message_sizes[0] = 2000;
  params.message_sizes[0] = 10000;
  params.num_message_sizes = 1;
  params.iter = 2;
  params.verify = 0;
  params.verbose = 0;
  //params.verify = 1;
  //params.verbose = 1;
  status = pamix_collsel_table_generate (advisor, NULL, &params, 1);

  pami_extension_collsel_destroy pamix_collsel_destroy =
    (pami_extension_collsel_destroy) PAMI_Extension_symbol (extension, "Collsel_destroy_fn");
  if (pamix_collsel_destroy == (void *)NULL)
  {
    fprintf (stderr, "Error. The \"EXT_collsel\" extension function \"Collsel_destroy_fn\" is not implemented. result = %d\n", status);
    return 1;
  }
  status = pamix_collsel_destroy (advisor);
  //printf("after collsel destroy\n");

  free(params.collectives);
  free(params.geometry_sizes);
  free(params.message_sizes);

  status = PAMI_Extension_close (extension);
  if(status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error. The \"EXT_collsel\" extension could not be closed. result = %d\n", status);
    return 1;
  }
  //printf("after extension close\n");


  /* ------------------------------------------------------------------------ */
  status = PAMI_Context_destroyv(&context, 1);
  if(status != PAMI_SUCCESS)
  {
    fprintf(stderr, "Error. Unable to destroy pami context. result = %d\n", status);
    return 1;
  }
  //printf("after context destroy\n");

  status = PAMI_Client_destroy(&client);
  if(status != PAMI_SUCCESS)
  {
    fprintf(stderr, "Error. Unable to finalize pami client. result = %d\n", status);
    return 1;
  }
  //printf("after client destroy\n");

  return 0;
}
Esempio n. 8
0
int main(int argc, char ** argv)
{
  pami_client_t client;
  pami_context_t context;
  pami_result_t status = PAMI_ERROR;

  status = PAMI_Client_create("TEST", &client, NULL, 0);
  if(status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error. Unable to initialize pami client. result = %d\n", status);
    return 1;
  }
  DBG_FPRINTF((stderr,"Client %p\n",client));

  status = PAMI_Context_createv(client, NULL, 0, &context, 1);
  if(status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error. Unable to create pami context. result = %d\n", status);
    return 1;
  }

  /* ------------------------------------------------------------------------ */

  pami_extension_t extension;
  status = PAMI_Extension_open (client, "EXT_torus_network", &extension);
  if(status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error. The \"EXT_torus_network\" extension is not implemented. result = %d\n", status);
    return 1;
  }

  pami_extension_torus_information_fn pamix_torus_info =
    (pami_extension_torus_information_fn) PAMI_Extension_symbol (extension, "information");
  if (pamix_torus_info == (void *)NULL)
  {
    fprintf (stderr, "Error. The \"EXT_torus_network\" extension function \"information\" is not implemented. result = %d\n", status);
    return 1;
  }

  const pami_extension_torus_information_t * info = pamix_torus_info ();

  fprintf (stdout, "Torus Dimensions:  %zu\n", info->dims);

  char str[1024];
  size_t i, nchars;

  for (nchars=i=0; i<(info->dims-1); i++)
    nchars += snprintf (&str[nchars],1023-nchars, "%zu,", info->coord[i]);
  nchars += snprintf (&str[nchars],1023-nchars, "%zu", info->coord[info->dims-1]);
  fprintf (stdout, "Torus Coordinates: [%s]\n", str);

  for (nchars=i=0; i<(info->dims-1); i++)
    nchars += snprintf (&str[nchars],1023-nchars, "%zu,", info->size[i]);
  nchars += snprintf (&str[nchars],1023-nchars, "%zu", info->size[info->dims-1]);
  fprintf (stdout, "Torus Size:        [%s]\n", str);

  for (nchars=i=0; i<(info->dims-1); i++)
    nchars += snprintf (&str[nchars],1023-nchars, "%zu,", info->torus[i]);
  nchars += snprintf (&str[nchars],1023-nchars, "%zu", info->torus[info->dims-1]);
  fprintf (stdout, "Torus Wrap:        [%s]\n", str);



  pami_extension_torus_task2torus_fn pamix_torus_task2torus =
    (pami_extension_torus_task2torus_fn) PAMI_Extension_symbol (extension, "task2torus");
  if (pamix_torus_task2torus == (void *)NULL)
  {
    fprintf (stderr, "Error. The \"EXT_torus_network\" extension function \"task2torus\" is not implemented. result = %d\n", status);
    return 1;
  }

  pami_task_t task = 1;
  size_t * coord = (size_t *) malloc (sizeof(size_t) * info->dims);
  status = pamix_torus_task2torus (task, coord);
  if (status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error.  Unable to query the torus coordinates of task 1\n");
    return 1;
  }

  for (nchars=i=0; i<(info->dims-1); i++)
    nchars += snprintf (&str[nchars],1023-nchars, "%zu,", coord[i]);
  nchars += snprintf (&str[nchars],1023-nchars, "%zu", coord[i]);
  fprintf (stdout, "Task 1 Torus Coordinates:     [%s]\n", str);


  pami_extension_torus_torus2task_fn pamix_torus_torus2task =
    (pami_extension_torus_torus2task_fn) PAMI_Extension_symbol (extension, "torus2task");
  if (pamix_torus_torus2task == (void *)NULL)
  {
    fprintf (stderr, "Error. The \"EXT_torus_network\" extension function \"torus2task\" is not implemented. result = %d\n", status);
    return 1;
  }

  /*coord[0] = 0; */
  /*coord[1] = 0; */
  /*coord[2] = 0; */
  /*coord[3] = 1; */
  status = pamix_torus_torus2task (coord, &task);
  if (status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error.  Unable to query the task for coordinates [%zu,%zu,%zu,%zu]\n",coord[0],coord[1],coord[2],coord[3]);
    return 1;
  }
  for (nchars=i=0; i<(info->dims-1); i++)
    nchars += snprintf (&str[nchars],1023-nchars, "%zu,", coord[i]);
  nchars += snprintf (&str[nchars],1023-nchars, "%zu", coord[i]);
  fprintf (stdout, "Task at Torus Coordinates [%s]: %d\n", str, task);;






  status = PAMI_Extension_close (extension);
  if(status != PAMI_SUCCESS)
  {
    fprintf (stderr, "Error. The \"EXT_torus_network\" extension could not be closed. result = %d\n", status);
    return 1;
  }


  /* ------------------------------------------------------------------------ */
  DBG_FPRINTF((stderr, "PAMI_Context_destroyv(&context, 1);\n"));
  status = PAMI_Context_destroyv(&context, 1);
  if(status != PAMI_SUCCESS)
  {
    fprintf(stderr, "Error. Unable to destroy pami context. result = %d\n", status);
    return 1;
  }

  DBG_FPRINTF((stderr, "PAMI_Client_destroy(&client);\n"));
  status = PAMI_Client_destroy(&client);
  if(status != PAMI_SUCCESS)
  {
    fprintf(stderr, "Error. Unable to finalize pami client. result = %d\n", status);
    return 1;
  }

  DBG_FPRINTF((stderr, "return 0;\n"));
  return 0;
}