sphor.h (3408B)
1 /* Copyright (C) 2024-2026 Centre National de la Recherche Scientifique 2 * Copyright (C) 2024-2026 Clermont Auvergne INP 3 * Copyright (C) 2024-2026 INSA Lyon 4 * Copyright (C) 2024-2026 Institut Mines Télécom Albi-Carmaux 5 * Copyright (C) 2024-2026 Institut National Polytechnique de Toulouse 6 * Copyright (C) 2024-2026 |Méso|Star> (contact@meso-star.com) 7 * Copyright (C) 2024-2026 PhotonLyX (info@photonlyx.com) 8 * Copyright (C) 2024-2026 Université de Lorraine 9 * Copyright (C) 2024-2026 Université Paul Sabatier 10 * Copyright (C) 2024-2026 Université Toulouse - Jean Jaurès 11 * 12 * This program is free software: you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation, either version 3 of the License, or 15 * (at your option) any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 24 25 #ifndef SPHOR_H 26 #define SPHOR_H 27 28 #include <rsys/rsys.h> 29 30 #include <limits.h> 31 32 /* Library symbol management */ 33 #if defined(SPHOR_SHARED_BUILD) /* Directive defined only when building 34 star-phor (see Makefile) */ 35 #define SPHOR_API extern EXPORT_SYM /* When building star-phor */ 36 #else 37 #define SPHOR_API extern IMPORT_SYM /* When using star-phor */ 38 #endif 39 40 /* Helper macro that asserts if the invocation of the sphor function `Func' 41 * returns an error. One should use this macro on sphor function calls for which 42 * no explicit error checking is performed */ 43 #ifndef NDEBUG 44 #define SPHOR(Func) ASSERT(sphor_##Func == RES_OK) 45 #else 46 #define SPHOR(Func) sphor_##Func 47 #endif 48 49 struct sphor_create_args { 50 struct logger* logger; /* May be NULL <=> default logger */ 51 struct mem_allocator* allocator; /* NULL <=> use default allocator */ 52 int verbose; /* Verbosity level. Bigger values => more verbosity */ 53 54 unsigned nthreads; /* hint: number of threads; defaults to all available 55 threads in the computer */ 56 size_t samples; /* number of realisations used during the Monte Carlo 57 integrating algorithm */ 58 char* input_filename; /* May be NULL <=> uses stdin */ 59 char* output_filename; /* May be NULL <=> uses stdout */ 60 int force; /* Either force overwriting (1) or return an error (0) 61 if the output file already exists */ 62 }; 63 64 #define SPHOR_CREATE_ARGS_DEFAULT__ {\ 65 NULL,\ 66 NULL,\ 67 0,\ 68 UINT_MAX,\ 69 10000,\ 70 NULL,\ 71 NULL,\ 72 0} 73 74 static const struct sphor_create_args SPHOR_CREATE_ARGS_DEFAULT = 75 SPHOR_CREATE_ARGS_DEFAULT__; 76 77 /* Forward declarations */ 78 struct sphor; 79 80 BEGIN_DECLS 81 82 /******************************************************************************* 83 * API of the sphor handle 84 ******************************************************************************/ 85 SPHOR_API res_T 86 sphor_create 87 (const struct sphor_create_args* args, 88 struct sphor** sphor); 89 90 SPHOR_API res_T 91 sphor_run 92 (struct sphor* sphor); 93 94 SPHOR_API res_T 95 sphor_ref_put 96 (struct sphor* sphor); 97 98 SPHOR_API res_T 99 sphor_ref_get 100 (struct sphor* sphor); 101 102 END_DECLS 103 104 #endif /* SPHOR_H */