Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
deprecate SIMIX_is_maestro
[simgrid.git] / include / simgrid / simix.h
1 /* Copyright (c) 2007-2021. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_SIMIX_H
7 #define SIMGRID_SIMIX_H
8
9 #include <simgrid/forward.h>
10 #include <xbt/dynar.h>
11 #include <xbt/ex.h>
12 #include <xbt/parmap.h>
13 #ifdef __cplusplus
14 #include <functional>
15 #include <string>
16 #include <unordered_map>
17 #include <vector>
18 #endif
19
20 /******************************* Networking ***********************************/
21 SG_BEGIN_DECL
22
23 XBT_ATTRIB_DEPRECATED_v331("Please use sg_actor_by_pid() instead.") XBT_PUBLIC smx_actor_t
24     SIMIX_process_from_PID(aid_t pid);
25
26 /* parallelism */
27 XBT_ATTRIB_DEPRECATED_v333("Please use kernel::context::is_parallel()") XBT_PUBLIC int SIMIX_context_is_parallel();
28 XBT_ATTRIB_DEPRECATED_v333("Please use kernel::context::get_nthreads()") XBT_PUBLIC int SIMIX_context_get_nthreads();
29 XBT_ATTRIB_DEPRECATED_v333("Please use kernel::context::set_nthreads()") XBT_PUBLIC
30     void SIMIX_context_set_nthreads(int nb_threads);
31 XBT_ATTRIB_DEPRECATED_v333("Please use kernel::context::get_parallel_mode()") XBT_PUBLIC e_xbt_parmap_mode_t
32     SIMIX_context_get_parallel_mode();
33 XBT_ATTRIB_DEPRECATED_v333("Please use kernel::context::set_parallel_mode()") XBT_PUBLIC
34     void SIMIX_context_set_parallel_mode(e_xbt_parmap_mode_t mode);
35 XBT_ATTRIB_DEPRECATED_v333("Please use Actor::is_maestro()") XBT_PUBLIC int SIMIX_is_maestro();
36
37 /********************************** Global ************************************/
38 /* Set some code to execute in the maestro (must be used before the engine creation)
39  *
40  * If no maestro code is registered (the default), the main thread
41  * is assumed to be the maestro. */
42 XBT_ATTRIB_DEPRECATED_v333("Please use simgrid_set_maestro()") XBT_PUBLIC
43     void SIMIX_set_maestro(void (*code)(void*), void* data);
44
45 /* Simulation execution */
46 XBT_ATTRIB_DEPRECATED_v332("Please use EngineImpl:run()") XBT_PUBLIC void SIMIX_run();
47 XBT_ATTRIB_DEPRECATED_v332("Please use simgrid_get_clock() or Engine::get_clock()") XBT_PUBLIC double SIMIX_get_clock();
48
49 SG_END_DECL
50
51 /********************************* Process ************************************/
52 SG_BEGIN_DECL
53 XBT_ATTRIB_DEPRECATED_v333("Please use kernel::actor::ActorImpl::self()") XBT_PUBLIC smx_actor_t SIMIX_process_self();
54 XBT_ATTRIB_DEPRECATED_v333("Please use xbt_procname()") XBT_PUBLIC const char* SIMIX_process_self_get_name();
55 SG_END_DECL
56
57 /****************************** Communication *********************************/
58 #ifdef __cplusplus
59 XBT_ATTRIB_DEPRECATED_v333("Please use Engine::set_default_comm_data_copy_callback()") XBT_PUBLIC
60     void SIMIX_comm_set_copy_data_callback(void (*callback)(simgrid::kernel::activity::CommImpl*, void*, size_t));
61
62 XBT_ATTRIB_DEPRECATED_v333("Please use Comm::copy_buffer_callback()") XBT_PUBLIC
63     void SIMIX_comm_copy_pointer_callback(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size);
64 XBT_ATTRIB_DEPRECATED_v333("Please use Comm::copy_pointer_callback()") XBT_PUBLIC
65     void SIMIX_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, void* buff, size_t buff_size);
66 #endif
67
68 /******************************************************************************/
69 /*                            SIMIX simcalls                                  */
70 /******************************************************************************/
71 /* These functions are a system call-like interface to the simulation kernel. */
72 /* They can also be called from maestro's context, and they are thread safe.  */
73 /******************************************************************************/
74
75 /******************************* Host simcalls ********************************/
76 #ifdef __cplusplus
77 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::wait_for()") XBT_PUBLIC simgrid::kernel::activity::State
78     simcall_execution_wait(simgrid::kernel::activity::ActivityImpl* execution, double timeout);
79 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::wait_for()") XBT_PUBLIC simgrid::kernel::activity::State
80     simcall_execution_wait(const simgrid::kernel::activity::ActivityImplPtr& execution, double timeout);
81 XBT_ATTRIB_DEPRECATED_v331("Please use s4u::Exec::wait_any_for()") XBT_PUBLIC
82     unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count,
83                                                double timeout);
84 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::test()") XBT_PUBLIC
85     bool simcall_execution_test(simgrid::kernel::activity::ActivityImpl* execution);
86 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Exec::test()") XBT_PUBLIC
87     bool simcall_execution_test(const simgrid::kernel::activity::ActivityImplPtr& execution);
88
89 #endif
90
91 /************************** Communication simcalls ****************************/
92
93 #ifdef __cplusplus
94 XBT_PUBLIC void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
95                                   size_t src_buff_size,
96                                   bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
97                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
98                                   void* data, double timeout);
99
100 XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr
101 simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
102                    size_t src_buff_size, bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
103                    void (*clean_fun)(void*), void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
104                    void* data, bool detached);
105
106 XBT_PUBLIC void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
107                                   bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
108                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
109                                   void* data, double timeout, double rate);
110
111 XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr
112 simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
113                    bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
114                    void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, double rate);
115
116 XBT_ATTRIB_DEPRECATED_v330("Please use Mailbox::iprobe()") XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr
117     simcall_comm_iprobe(smx_mailbox_t mbox, int type,
118                         bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data);
119
120 XBT_ATTRIB_DEPRECATED_v330("Please use a CommImpl*[] for first parameter") XBT_PUBLIC
121     unsigned int simcall_comm_waitany(simgrid::kernel::activity::ActivityImplPtr comms[], size_t count, double timeout);
122 XBT_PUBLIC ssize_t simcall_comm_waitany(simgrid::kernel::activity::CommImpl* comms[], size_t count, double timeout);
123 XBT_PUBLIC void simcall_comm_wait(simgrid::kernel::activity::ActivityImpl* comm, double timeout);
124 XBT_PUBLIC bool simcall_comm_test(simgrid::kernel::activity::ActivityImpl* comm);
125 XBT_ATTRIB_DEPRECATED_v330("Please use a CommImpl*[] for first parameter") XBT_PUBLIC
126     int simcall_comm_testany(simgrid::kernel::activity::ActivityImplPtr comms[], size_t count);
127 XBT_PUBLIC ssize_t simcall_comm_testany(simgrid::kernel::activity::CommImpl* comms[], size_t count);
128
129 XBT_ATTRIB_DEPRECATED_v330("Please use an ActivityImpl* for first parameter") inline void simcall_comm_wait(
130     const simgrid::kernel::activity::ActivityImplPtr& comm, double timeout)
131 {
132   simcall_comm_wait(comm.get(), timeout);
133 }
134 XBT_ATTRIB_DEPRECATED_v330("Please use an ActivityImpl* for first parameter") inline bool simcall_comm_test(
135     const simgrid::kernel::activity::ActivityImplPtr& comm)
136 {
137   return simcall_comm_test(comm.get());
138 }
139 #endif
140
141 /************************** Synchro simcalls **********************************/
142 SG_BEGIN_DECL
143 XBT_ATTRIB_DEPRECATED_v330("Please use sg_mutex_init()") XBT_PUBLIC smx_mutex_t simcall_mutex_init();
144 XBT_ATTRIB_DEPRECATED_v331("Please use sg_mutex_lock()") XBT_PUBLIC void simcall_mutex_lock(smx_mutex_t mutex);
145 XBT_ATTRIB_DEPRECATED_v331("Please use sg_mutex_try_lock()") XBT_PUBLIC int simcall_mutex_trylock(smx_mutex_t mutex);
146 XBT_ATTRIB_DEPRECATED_v331("Please use sg_mutex_unlock()") XBT_PUBLIC void simcall_mutex_unlock(smx_mutex_t mutex);
147
148 XBT_ATTRIB_DEPRECATED_v330("Please use sg_cond_init()") XBT_PUBLIC smx_cond_t simcall_cond_init();
149 XBT_ATTRIB_DEPRECATED_v331("Please use sg_cond_wait()") XBT_PUBLIC
150     void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
151 XBT_ATTRIB_DEPRECATED_v331("Please use sg_cond_wait_for()") XBT_PUBLIC
152     int simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double max_duration);
153
154 XBT_ATTRIB_DEPRECATED_v331("Please use sg_sem_acquire()") XBT_PUBLIC void simcall_sem_acquire(smx_sem_t sem);
155 XBT_ATTRIB_DEPRECATED_v331("Please use sg_sem_acquire_timeout()") XBT_PUBLIC
156     int simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration);
157 SG_END_DECL
158
159 /*****************************   Io   **************************************/
160 #ifdef __cplusplus
161 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Io::wait_for()") XBT_PUBLIC simgrid::kernel::activity::State
162     simcall_io_wait(simgrid::kernel::activity::ActivityImpl* io, double timeout);
163 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Io::wait_for()") XBT_PUBLIC simgrid::kernel::activity::State
164     simcall_io_wait(const simgrid::kernel::activity::ActivityImplPtr& io, double timeout);
165 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Io::test()") XBT_PUBLIC
166     bool simcall_io_test(simgrid::kernel::activity::ActivityImpl* io);
167 XBT_ATTRIB_DEPRECATED_v330("Please use s4u::Io::test()") XBT_PUBLIC
168     bool simcall_io_test(const simgrid::kernel::activity::ActivityImplPtr& io);
169 #endif
170 /************************** MC simcalls   **********************************/
171 SG_BEGIN_DECL
172 XBT_ATTRIB_DEPRECATED_v331("Please use MC_random()") XBT_PUBLIC int simcall_mc_random(int min, int max);
173 SG_END_DECL
174
175 #endif