ALP User Documentation 0.7.0
Algebraic Programming User Documentation
exec.hpp
Go to the documentation of this file.
1
2/*
3 * Copyright 2021 Huawei Technologies Co., Ltd.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
27#ifndef _H_GRB_EXEC_BASE
28#define _H_GRB_EXEC_BASE
29
30#include <stdexcept>
31#include <string>
32
34#include <graphblas/rc.hpp>
35
36#ifndef _GRB_NO_STDIO
37 #include <iostream>
38#endif
39
40
41namespace grb {
42
56 enum EXEC_MODE {
57
63
70
77
78 };
79
96 template< enum EXEC_MODE mode, enum Backend backend >
97 class Launcher {
98
99 public :
100
141 const size_t process_id = 0,
142 const size_t nprocs = 1,
143 const std::string hostname = "localhost",
144 const std::string port = "0"
145 ) {
146 // spec does not specify any constrants on hostname and port
147 // so accept (and ignore) anything
148 (void) hostname; (void) port;
149
150#ifndef _GRB_NO_EXCEPTIONS
151 // sanity checks on process_id and nprocs
152 if( nprocs == 0 ) {
153 throw std::invalid_argument( "Total number of user processes must be "
154 "strictly larger than zero." );
155 }
156 if( process_id >= nprocs ) {
157 throw std::invalid_argument( "Process ID must be strictly smaller than "
158 "total number of user processes." );
159 }
160#endif
161 }
162
209 template< typename T, typename U >
211 void ( *alp_program )( const T &, U & ),
212 const T &data_in,
213 U &data_out,
214 const bool broadcast = false
215 ) const {
216 (void) alp_program;
217 (void) data_in;
218 (void) data_out;
219 (void) broadcast;
220 // stub implementation, should be overridden by specialised backend,
221 // so return error code
222 return PANIC;
223 }
224
251 template< typename U >
253 void ( *alp_program )( const void *, const size_t, U & ),
254 const void * data_in,
255 const size_t in_size,
256 U &data_out,
257 const bool broadcast = false
258 ) const {
259 (void) alp_program;
260 (void) data_in;
261 (void) in_size;
262 (void) data_out;
263 (void) broadcast;
264 return PANIC;
265 }
266
322 static RC finalize() {
323 return PANIC;
324 }
325
326 }; // end class `Launcher'
327
328} // end namespace ``grb''
329
330#endif // end _H_GRB_EXEC_BASE
331
This file contains a register of all backends that are either implemented, under implementation,...
A group of user processes that together execute ALP programs.
Definition: exec.hpp:97
Launcher(const size_t process_id=0, const size_t nprocs=1, const std::string hostname="localhost", const std::string port="0")
Constructs a new grb::Launcher.
Definition: exec.hpp:140
RC exec(void(*alp_program)(const void *, const size_t, U &), const void *data_in, const size_t in_size, U &data_out, const bool broadcast=false) const
Executes a given ALP program using the user processes encapsulated by this launcher group.
Definition: exec.hpp:252
static RC finalize()
Releases all ALP resources.
Definition: exec.hpp:322
RC exec(void(*alp_program)(const T &, U &), const T &data_in, U &data_out, const bool broadcast=false) const
Executes a given ALP program using the user processes encapsulated by this launcher group.
Definition: exec.hpp:210
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:452
EXEC_MODE
The various ways in which the grb::Launcher can be used to execute an ALP program.
Definition: exec.hpp:56
@ AUTOMATIC
Automatic mode.
Definition: exec.hpp:62
@ MANUAL
Manual mode.
Definition: exec.hpp:69
@ FROM_MPI
When running from an MPI program.
Definition: exec.hpp:76
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
@ PANIC
Generic fatal error code.
Definition: rc.hpp:68
Defines the ALP error codes.