NewMadeleine

Documentation

« back to PM2 home.
nm_onesided_simple.c
/*
* NewMadeleine
* Copyright (C) 2006-2021 (see AUTHORS file)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include "../common/nm_examples_helper.h"
#include <stdio.h>
static int a = 0;
int main(int argc, char**argv)
{
const nm_tag_t tag = 0x01;
nm_examples_init(&argc, argv);
/* intialize the onesided interface */
nm_onesided_t p_onesided;
nm_onesided_init(p_session, &p_onesided);
{
/* ** target side */
/* send address of variable 'a' */
int*p_a = &a;
nm_sr_send(p_session, p_gate, tag, &p_a, sizeof(int*));
/* 1. target of non-blocking put */
printf("a = %d (1)\n", a);
/* 2. target of blocking put */
printf("a = %d (2)\n", a);
/* 3. target of non-blocking get */
a = 3;
/* 4. target-side completion for a put, NULL completion data */
nm_onesided_target_irecv(p_onesided, p_gate, NULL, 0, &target_req);
printf("a = %d (4)\n", a);
/* 5. target-side completion for a put, non-NULL completion data */
int c = 0;
nm_onesided_target_irecv(p_onesided, p_gate, &c, sizeof(c), &target_req);
printf("a = %d (5); c = %d (1)\n", a, c);
a = 6;
/* 6. target-side completion for a get */
c = 0;
nm_onesided_target_irecv(p_onesided, p_gate, &c, sizeof(c), &target_req);
printf("c = %d (1)\n", c);
}
else
{
/* ** initiator side */
/* receive address for remote variable 'a' */
int*p_a = NULL;
nm_sr_recv(p_session, p_gate, tag, &p_a, sizeof(int*));
a = 1;
/* build data descriptor for local a */
struct nm_data_s data;
nm_data_contiguous_build(&data, &a, sizeof(a));
/* 1. non-blocking put */
nm_onesided_iput_data(p_onesided, p_gate, &data, (uintptr_t)p_a, &req);
nm_onesided_ifence(p_onesided, p_gate, &freq);
nm_onesided_request_t*reqs[2] = { &req, &freq };;
/* 2. blocking put */
a = 2;
nm_onesided_put(p_onesided, p_gate, &a, sizeof(a), (uintptr_t)p_a);
nm_onesided_fence(p_onesided, p_gate);
/* 3. non-blocking get */
nm_onesided_iget_data(p_onesided, p_gate, &data, (uintptr_t)p_a, &req);
printf("a = %d (3)\n", a);
/* 4. put with target-side completion, NULL completion data */
a = 4;
nm_onesided_iput_with_target(p_onesided, p_gate, &a, sizeof(a), (uintptr_t)p_a, NULL, 0, &req);
/* 5. put with target-side completion, non-NULL completion data */
int c = 1;
a = 5;
nm_onesided_iput_with_target(p_onesided, p_gate, &a, sizeof(a), (uintptr_t)p_a, &c, sizeof(c), &req);
/* 6. get with target-side completion */
nm_onesided_iget_with_target(p_onesided, p_gate, &a, sizeof(a), (uintptr_t)p_a, &c, sizeof(c), &req);
printf("a = %d (6)\n", a);
}
/* stop the onesided interface */
nm_onesided_finalize(p_onesided);
}
void nm_coll_barrier(nm_comm_t comm, nm_tag_t tag)
void nm_onesided_put(nm_onesided_t p_onesided, struct nm_gate_s *p_gate, void *p_ptr, nm_len_t len, uintptr_t dest_addr)
blocking version of iput
void nm_onesided_fence(nm_onesided_t p_onesided, struct nm_gate_s *p_gate)
blocking version of ifence
void nm_onesided_finalize(nm_onesided_t p_onesided)
void nm_onesided_init(nm_session_t p_session, nm_onesided_t *pp_onesided)
initialize the interface, using the given session.
void nm_onesided_ifence(nm_onesided_t p_onesided, struct nm_gate_s *p_gate, nm_onesided_request_t *p_req)
ensures all put operations to the remote node are completed
void nm_onesided_iput_data(nm_onesided_t p_onesided, struct nm_gate_s *p_gate, struct nm_data_s *p_data, uintptr_t dest_addr, nm_onesided_request_t *p_req)
remotely write to destination memory; local data described by p_data; dest_addr is the address in the...
void nm_onesided_req_wait(nm_onesided_request_t *p_req)
wait for this request completion
void nm_onesided_iget_data(nm_onesided_t p_onesided, struct nm_gate_s *p_gate, struct nm_data_s *p_data, uintptr_t dest_addr, nm_onesided_request_t *p_req)
remotely read data from target memory (nm_data flavor).
void nm_onesided_req_wait_all(nm_onesided_request_t **p_reqs, int n)
wait for completion of a vector of requests
void nm_onesided_iput_with_target(nm_onesided_t p_onesided, struct nm_gate_s *p_gate, void *p_ptr, nm_len_t len, uintptr_t dest_addr, void *p_target_ptr, nm_len_t target_len, nm_onesided_request_t *p_req)
send a put request with target-side completion.
void nm_onesided_target_irecv(nm_onesided_t p_onesided, nm_gate_t p_gate, void *p_ptr, nm_len_t len, nm_onesided_target_request_t *p_req)
posts a recv request for target-side completion
void nm_onesided_iget_with_target(nm_onesided_t p_onesided, struct nm_gate_s *p_gate, void *p_ptr, nm_len_t len, uintptr_t dest_addr, void *p_target_ptr, nm_len_t target_len, nm_onesided_request_t *p_req)
send a get request with target-side completion
void nm_onesided_target_wait(nm_onesided_target_request_t *p_req)
wait completion of a request on target side
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)
Definition nm_data.h:355
static nm_comm_t p_comm
static int is_server
static void nm_examples_init(int *argc, char *argv[])
static nm_session_t p_session
static void nm_examples_exit(void)
static nm_gate_t p_gate
uint64_t req
a type of debug request; unused for now
Definition nm_headers.h:1
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
static int nm_sr_send(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, const void *data, nm_len_t len)
blocking send
uint64_t nm_tag_t
user tags, 64 bits, contained in indirect hashtable
Definition nm_types.h:56
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Definition nm_data.h:196
a send request for onesided
an instance of interface 'onesided'
a request used for target-side completions