#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
struct user_data_s
{
char**array;
int num;
};
{
.p_generator_init = NULL,
.p_generator_next = NULL
};
NM_DATA_TYPE(user_data,
struct user_data_s, &user_data_ops);
static void user_data_traversal(
const void*_content,
nm_data_apply_t apply,
void*_context)
{
const struct user_data_s*content = _content;
int i;
for(i = 0; i < content->num; i++)
{
(*apply)(content->array[i], content->len, _context);
}
}
int main(int argc, char**argv)
{
int num = 200;
char**array = malloc(sizeof(char*) * num);
int i;
for(i = 0; i < num; i++)
{
if(rank == 0)
{
int j;
for(j = 0; j <
len - 1; j++)
{
array[i][j] = 'a' + ((i + j) % 26);
}
array[i][
len - 1] =
'\0';
}
}
nm_data_user_data_set(&data, (
struct user_data_s){ .array = array, .num = num, .len =
len });
if(rank == 0)
{
}
else if(rank ==
size - 1)
{
printf("received data on node %d:\n", rank);
for(i = 0; i < num; i++)
{
printf("%s\n", array[i]);
}
}
else
{
}
for(i = 0; i < num; i++)
{
free(array[i]);
}
free(array);
return 0;
}
struct nm_core_event_s __attribute__
int nm_launcher_get_rank(int *rank)
Returns process rank.
int nm_launcher_get_size(int *size)
Returns the number of nodes.
int nm_launcher_exit(void)
Cleans session.
int nm_launcher_get_gate(int dest, nm_gate_t *gate)
Returns the gate for the process dest.
static int nm_launcher_init(int *argc, char **argv)
Initializes nmad.
void(* nm_data_apply_t)(void *ptr, nm_len_t len, void *_context)
function to apply to each data chunk upon traversal
#define NM_DATA_TYPE(ENAME, CONTENT_TYPE, OPS)
macro to generate typed functions to init/access data fields.
int nm_session_open(nm_session_t *pp_session, const char *label)
Open a new session, assuming processes are already connected.
int nm_session_close(nm_session_t p_session)
Disconnect and destroy a session.
nm_tag_t tag
the user-supplied tag
static nm_session_t p_session
nm_len_t size
size of the onsided data (not incuding target-side completion)
static int nm_sr_isend_data(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, struct nm_data_s *p_data, nm_sr_request_t *p_request)
static int nm_sr_swait(nm_session_t p_session, nm_sr_request_t *p_request)
Wait for the completion of a non blocking send request.
static int nm_sr_rwait(nm_session_t p_session, nm_sr_request_t *p_request)
Wait for the completion of a non blocking receive request.
static int nm_sr_irecv_data(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, struct nm_data_s *p_data, nm_sr_request_t *p_request)
uint64_t nm_tag_t
user tags, 64 bits, contained in indirect hashtable
uint64_t nm_len_t
data length used by nmad
set of operations available on data type.
nm_data_traversal_t p_traversal
operation to apply a given function to all chunks of data (required)
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Connection to another process.
internal defintion of the sendrecv request