Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove deprecated features for next release (3.30).
[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_v331("Please use s4u::Exec::wait_any_for()") XBT_PUBLIC
78     unsigned int simcall_execution_waitany_for(simgrid::kernel::activity::ExecImpl* execs[], size_t count,
79                                                double timeout);
80 #endif
81
82 /************************** Communication simcalls ****************************/
83
84 #ifdef __cplusplus
85 XBT_PUBLIC void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
86                                   size_t src_buff_size,
87                                   bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
88                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
89                                   void* data, double timeout);
90
91 XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr
92 simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff,
93                    size_t src_buff_size, bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
94                    void (*clean_fun)(void*), void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
95                    void* data, bool detached);
96
97 XBT_PUBLIC void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
98                                   bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
99                                   void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t),
100                                   void* data, double timeout, double rate);
101
102 XBT_PUBLIC simgrid::kernel::activity::ActivityImplPtr
103 simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size,
104                    bool (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*),
105                    void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, double rate);
106
107 XBT_PUBLIC ssize_t simcall_comm_waitany(simgrid::kernel::activity::CommImpl* comms[], size_t count, double timeout);
108 XBT_PUBLIC void simcall_comm_wait(simgrid::kernel::activity::ActivityImpl* comm, double timeout);
109 XBT_PUBLIC bool simcall_comm_test(simgrid::kernel::activity::ActivityImpl* comm);
110 XBT_PUBLIC ssize_t simcall_comm_testany(simgrid::kernel::activity::CommImpl* comms[], size_t count);
111
112 #endif
113
114 /************************** Synchro simcalls **********************************/
115 SG_BEGIN_DECL
116 XBT_ATTRIB_DEPRECATED_v331("Please use sg_mutex_lock()") XBT_PUBLIC void simcall_mutex_lock(smx_mutex_t mutex);
117 XBT_ATTRIB_DEPRECATED_v331("Please use sg_mutex_try_lock()") XBT_PUBLIC int simcall_mutex_trylock(smx_mutex_t mutex);
118 XBT_ATTRIB_DEPRECATED_v331("Please use sg_mutex_unlock()") XBT_PUBLIC void simcall_mutex_unlock(smx_mutex_t mutex);
119
120 XBT_ATTRIB_DEPRECATED_v331("Please use sg_cond_wait()") XBT_PUBLIC
121     void simcall_cond_wait(smx_cond_t cond, smx_mutex_t mutex);
122 XBT_ATTRIB_DEPRECATED_v331("Please use sg_cond_wait_for()") XBT_PUBLIC
123     int simcall_cond_wait_timeout(smx_cond_t cond, smx_mutex_t mutex, double max_duration);
124
125 XBT_ATTRIB_DEPRECATED_v331("Please use sg_sem_acquire()") XBT_PUBLIC void simcall_sem_acquire(smx_sem_t sem);
126 XBT_ATTRIB_DEPRECATED_v331("Please use sg_sem_acquire_timeout()") XBT_PUBLIC
127     int simcall_sem_acquire_timeout(smx_sem_t sem, double max_duration);
128 SG_END_DECL
129
130 /************************** MC simcalls   **********************************/
131 SG_BEGIN_DECL
132 XBT_ATTRIB_DEPRECATED_v331("Please use MC_random()") XBT_PUBLIC int simcall_mc_random(int min, int max);
133 SG_END_DECL
134
135 #endif