#include <stdlib.h>
#include <stdio.h>
#include "../common/nm_examples_helper.h"
#define NB_EXCHANGES 10
int main(int argc, char** argv)
{
const char msg[] = "Hello, world!";
const nm_len_t msg_size = strlen(msg) + 1;
int worldsize;
if(worldsize == 1)
{
fprintf(stderr, "We need several nodes.\n");
return EXIT_FAILURE;
}
fprintf(stderr, "# With barrier, different tags...\n");
for (int k = 0; k < NB_EXCHANGES; k++)
{
{
int* dests = malloc(sizeof(int) * (worldsize - 1));
int i;
for (i = 1; i < worldsize; i++)
{
dests[i-1] = i;
}
free(dests);
}
else
{
char* buffer = malloc(msg_size);
if (strcmp(buffer, msg))
{
NM_FATAL(
"Received msg: '%s' (should be '%s')\n", buffer, msg);
}
free(buffer);
}
}
fprintf(stderr, "# With barrier, same tags...\n");
for (int k = 0; k < NB_EXCHANGES; k++)
{
{
int* dests = malloc(sizeof(int) * (worldsize - 1));
int i;
for (i = 1; i < worldsize; i++)
{
dests[i-1] = i;
}
free(dests);
}
else
{
char* buffer = malloc(msg_size);
if (strcmp(buffer, msg))
{
NM_FATAL(
"Received msg: '%s' (should be '%s')\n", buffer, msg);
}
free(buffer);
}
}
fprintf(stderr, "# Without barrier, different tags...\n");
for (int k = 0; k < NB_EXCHANGES; k++)
{
{
int* dests = malloc(sizeof(int) * (worldsize - 1));
int i;
for (i = 1; i < worldsize; i++)
{
dests[i-1] = i;
}
free(dests);
}
else
{
char* buffer = malloc(msg_size);
if (strcmp(buffer, msg))
{
NM_FATAL(
"Received msg: '%s' (should be '%s')\n", buffer, msg);
}
free(buffer);
}
}
fprintf(stderr, "# Without barrier, same tags...\n");
for (int k = 0; k < NB_EXCHANGES; k++)
{
{
int* dests = malloc(sizeof(int) * (worldsize - 1));
int i;
for (i = 1; i < worldsize; i++)
{
dests[i-1] = i;
}
free(dests);
}
else
{
char* buffer = malloc(msg_size);
if (strcmp(buffer, msg))
{
NM_FATAL(
"Received msg: '%s' (should be '%s')\n", buffer, msg);
}
free(buffer);
}
}
fprintf(stderr, "# Without barrier, same tags, binary tree...\n");
for (int k = 0; k < NB_EXCHANGES; k++)
{
{
int* dests = malloc(sizeof(int) * (worldsize - 1));
int i;
for (i = 1; i < worldsize; i++)
{
dests[i-1] = i;
}
free(dests);
}
else
{
char* buffer = malloc(msg_size);
if (strcmp(buffer, msg))
{
NM_FATAL(
"Received msg: '%s' (should be '%s')\n", buffer, msg);
}
free(buffer);
}
}
fprintf(stderr, "# Without barrier, same tags, chain tree...\n");
for (int k = 0; k < NB_EXCHANGES; k++)
{
{
int* dests = malloc(sizeof(int) * (worldsize - 1));
int i;
for (i = 1; i < worldsize; i++)
{
dests[i-1] = i;
}
free(dests);
}
else
{
char* buffer = malloc(msg_size);
if (strcmp(buffer, msg))
{
NM_FATAL(
"Received msg: '%s' (should be '%s')\n", buffer, msg);
}
free(buffer);
}
}
printf("success\n");
return EXIT_SUCCESS;
}
void nm_coll_barrier(nm_comm_t comm, nm_tag_t tag)
@ NM_COLL_TREE_DEFAULT
for public interfaces, will fallback to one of the previous tree kinds
int nm_launcher_get_size(int *size)
Returns the number of nodes.
void nm_mcast_send(nm_mcast_service_t nm_mcast, nm_comm_t p_recv_comm, int *p_dests, int *p_prios, int n_dests, nm_tag_t tag, struct nm_data_s *p_data, nm_len_t hlen, nm_coll_tree_kind_t tree_kind)
Send data in a blocking mode.
void nm_mcast_finalize(nm_mcast_service_t nm_mcast)
Release the mcast interface.
nm_mcast_service_t nm_mcast_init(nm_comm_t p_comm)
Initializes the mcast interface.
struct nm_mcast_service_s * nm_mcast_service_t
Public abstraction for a mcast service.
static nm_session_t nm_comm_get_session(nm_comm_t p_comm)
nm_tag_t tag
the user-supplied tag
static void nm_data_contiguous_build(struct nm_data_s *p_data, void *ptr, nm_len_t len)
static void nm_examples_exit(void)
static void nm_examples_init_topo(int *argc, char *argv[], enum nm_example_topo_e topo)
#define NM_FATAL(format,...)
nm_mpi_communicator_t * p_comm
communicator used for communication
static int nm_sr_recv(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, void *data, nm_len_t len)
blocking recv
uint64_t nm_tag_t
user tags, 64 bits, contained in indirect hashtable
uint64_t nm_len_t
data length used by nmad
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers