-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcall.c
135 lines (118 loc) · 3.86 KB
/
call.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// =============================================================================
// High Performance ParalleX Library (libhpx)
//
// Copyright (c) 2013-2016, Trustees of Indiana University,
// All rights reserved.
//
// This software may be modified and distributed under the terms of the BSD
// license. See the COPYING file for details.
//
// This software was created at the Indiana University Center for Research in
// Extreme Scale Technologies (CREST).
// =============================================================================
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
/// @file libhpx/call.c
/// @brief Implement the hpx/call.h header.
///
#include <string.h>
#include <stdarg.h>
#include <hpx/hpx.h>
#include <libhpx/action.h>
#include <libhpx/parcel.h>
#include <libhpx/scheduler.h>
/// A RPC call with a user-specified continuation action.
int _hpx_call_with_continuation(hpx_addr_t addr, hpx_action_t action,
hpx_addr_t c_target, hpx_action_t c_action,
int n, ...) {
va_list args;
va_start(args, n);
int e = action_call_lsync_va(action, addr, c_target, c_action, n, &args);
va_end(args);
return e;
}
int _hpx_call_async(hpx_addr_t addr, hpx_action_t id, hpx_addr_t lsync,
hpx_addr_t rsync, int n, ...) {
va_list args;
va_start(args, n);
hpx_action_t op = hpx_lco_set_action;
int e = action_call_async_va(id, addr, lsync, op, rsync, op, n, &args);
va_end(args);
return e;
}
/// Encapsulates an asynchronous remote-procedure-call.
int _hpx_call(hpx_addr_t addr, hpx_action_t id, hpx_addr_t result, int n, ...) {
va_list args;
va_start(args, n);
hpx_action_t rop = hpx_lco_set_action;
int e = action_call_lsync_va(id, addr, result, rop, n, &args);
va_end(args);
return e;
}
int _hpx_call_sync(hpx_addr_t addr, hpx_action_t id, void *out, size_t olen,
int n, ...) {
va_list args;
va_start(args, n);
int e = action_call_rsync_va(id, addr, out, olen, n, &args);
va_end(args);
return e;
}
int _hpx_call_cc(hpx_addr_t addr, hpx_action_t id, int n, ...) {
va_list args;
va_start(args, n);
hpx_parcel_t *p = self->current;
hpx_addr_t rsync = p->c_target;
hpx_action_t rop = p->c_action;
int e = action_call_lsync_va(id, addr, rsync, rop, n, &args);
va_end(args);
if (e == HPX_SUCCESS) {
p->c_target = HPX_NULL;
p->c_action = HPX_NULL;
e = hpx_thread_continue(NULL, 0);
}
return e;
}
int _hpx_call_when(hpx_addr_t gate, hpx_addr_t addr, hpx_action_t id,
hpx_addr_t result, int n, ...) {
va_list args;
va_start(args, n);
hpx_action_t rop = hpx_lco_set_action;
int e = action_when_lsync_va(id, addr, gate, result, rop, n, &args);
va_end(args);
return e;
}
int _hpx_call_when_sync(hpx_addr_t gate, hpx_addr_t addr, hpx_action_t id,
void *out, size_t olen, int n, ...) {
va_list args;
va_start(args, n);
int e = action_when_rsync_va(id, addr, gate, out, olen, n, &args);
va_end(args);
return e;
}
/// hpx_call_when with a user-specified continuation action.
int _hpx_call_when_with_continuation(hpx_addr_t gate, hpx_addr_t addr,
hpx_action_t id, hpx_addr_t rsync,
hpx_action_t rop, int n, ...) {
va_list args;
va_start(args, n);
int e = action_when_lsync_va(id, addr, gate, rsync, rop, n, &args);
va_end(args);
return e;
}
int _hpx_call_when_cc(hpx_addr_t gate, hpx_addr_t addr, hpx_action_t id, int n,
...) {
va_list args;
va_start(args, n);
hpx_parcel_t *p = self->current;
hpx_addr_t rsync = p->c_target;
hpx_action_t rop = p->c_action;
p->c_target = HPX_NULL;
p->c_action = HPX_NULL;
int e = action_when_lsync_va(id, addr, gate, rsync, rop, n, &args);
va_end(args);
if (e == HPX_SUCCESS) {
e = hpx_thread_continue(NULL, 0);
}
return e;
}