A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rename flag cfg=contexts/parallel to cfg=contexts/nthreads
[simgrid.git]
/
src
/
simix
/
smx_user.c
diff --git
a/src/simix/smx_user.c
b/src/simix/smx_user.c
index
3d1f880
..
3096246
100644
(file)
--- a/
src/simix/smx_user.c
+++ b/
src/simix/smx_user.c
@@
-1,6
+1,14
@@
#include "private.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
#include "private.h"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(simix);
+
+static const char* request_names[] = {
+#undef SIMIX_REQ_ENUM_ELEMENT
+#define SIMIX_REQ_ENUM_ELEMENT(x) #x /* generate strings from the enumeration values */
+SIMIX_REQ_LIST
+#undef SIMIX_REQ_ENUM_ELEMENT
+};
+
/**
* \brief Returns a host given its name.
*
/**
* \brief Returns a host given its name.
*
@@
-142,7
+150,8
@@
void SIMIX_req_host_set_data(smx_host_t host, void *data)
* \return A new SIMIX execution action
*/
smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
* \return A new SIMIX execution action
*/
smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
- double computation_amount)
+ double computation_amount,
+ double priority)
{
smx_req_t req = SIMIX_req_mine();
{
smx_req_t req = SIMIX_req_mine();
@@
-150,6
+159,7
@@
smx_action_t SIMIX_req_host_execute(const char *name, smx_host_t host,
req->host_execute.name = name;
req->host_execute.host = host;
req->host_execute.computation_amount = computation_amount;
req->host_execute.name = name;
req->host_execute.host = host;
req->host_execute.computation_amount = computation_amount;
+ req->host_execute.priority = priority;
SIMIX_request_push();
return req->host_execute.result;
}
SIMIX_request_push();
return req->host_execute.result;
}
@@
-269,24
+279,26
@@
void SIMIX_req_host_execution_set_priority(smx_action_t execution, double priori
}
/**
}
/**
- * \brief Waits for the completion of an execution action.
+ * \brief Waits for the completion of an execution action
and destroy it
.
*
* \param execution The execution action
*/
*
* \param execution The execution action
*/
-
void
SIMIX_req_host_execution_wait(smx_action_t execution)
+
e_smx_state_t
SIMIX_req_host_execution_wait(smx_action_t execution)
{
smx_req_t req = SIMIX_req_mine();
req->call = REQ_HOST_EXECUTION_WAIT;
req->host_execution_wait.execution = execution;
SIMIX_request_push();
{
smx_req_t req = SIMIX_req_mine();
req->call = REQ_HOST_EXECUTION_WAIT;
req->host_execution_wait.execution = execution;
SIMIX_request_push();
+ return req->host_execution_wait.result;
}
/**
* \brief Creates and runs a new SIMIX process.
*
}
/**
* \brief Creates and runs a new SIMIX process.
*
- * The structure and the corresponding thread
a
are created and put in the list of ready processes.
+ * The structure and the corresponding thread are created and put in the list of ready processes.
*
*
+ * \param process the process created will be stored in this pointer
* \param name a name for the process. It is for user-level information and can be NULL.
* \param code the main function of the process
* \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
* \param name a name for the process. It is for user-level information and can be NULL.
* \param code the main function of the process
* \param data a pointer to any data one may want to attach to the new object. It is for user-level information and can be NULL.
@@
-295,18
+307,18
@@
void SIMIX_req_host_execution_wait(smx_action_t execution)
* \param argc first argument passed to \a code
* \param argv second argument passed to \a code
* \param properties the properties of the process
* \param argc first argument passed to \a code
* \param argv second argument passed to \a code
* \param properties the properties of the process
- * \return The new process
*/
*/
-
smx_process_t SIMIX_req_process_create(
const char *name,
-
xbt_main_func_t code,
-
void *data,
-
const char *hostname,
-
int argc, char **argv,
-
xbt_dict_t properties)
+
void SIMIX_req_process_create(smx_process_t *process,
const char *name,
+ xbt_main_func_t code,
+ void *data,
+ const char *hostname,
+ int argc, char **argv,
+ xbt_dict_t properties)
{
smx_req_t req = SIMIX_req_mine();
req->call = REQ_PROCESS_CREATE;
{
smx_req_t req = SIMIX_req_mine();
req->call = REQ_PROCESS_CREATE;
+ req->process_create.process = process;
req->process_create.name = name;
req->process_create.code = code;
req->process_create.data = data;
req->process_create.name = name;
req->process_create.code = code;
req->process_create.data = data;
@@
-315,7
+327,6
@@
smx_process_t SIMIX_req_process_create(const char *name,
req->process_create.argv = argv;
req->process_create.properties = properties;
SIMIX_request_push();
req->process_create.argv = argv;
req->process_create.properties = properties;
SIMIX_request_push();
- return req->process_create.result;
}
/** \brief Kills a SIMIX process.
}
/** \brief Kills a SIMIX process.
@@
-363,6
+374,8
@@
void SIMIX_req_process_change_host(smx_process_t process, const char *source, co
*/
void SIMIX_req_process_suspend(smx_process_t process)
{
*/
void SIMIX_req_process_suspend(smx_process_t process)
{
+ xbt_assert0(process, "Invalid parameters");
+
smx_req_t req = SIMIX_req_mine();
req->call = REQ_PROCESS_SUSPEND;
smx_req_t req = SIMIX_req_mine();
req->call = REQ_PROCESS_SUSPEND;
@@
-553,12
+566,19
@@
void SIMIX_req_rdv_destroy(smx_rdv_t rdv)
smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
{
smx_rdv_t SIMIX_req_rdv_get_by_name(const char *name)
{
-
smx_req_t req = SIMIX_req_mine(
);
+
xbt_assert0(name != NULL, "Invalid parameter for SIMIX_req_rdv_get_by_name (name is NULL)"
);
+ /* FIXME: this is a horrible lost of performance, so we hack it out by
+ * skipping the request (for now). It won't work on distributed but
+ * probably we will change MSG for that. */
+/*
+ smx_req_t req = SIMIX_req_mine();
req->call = REQ_RDV_GEY_BY_NAME;
req->rdv_get_by_name.name = name;
SIMIX_request_push();
req->call = REQ_RDV_GEY_BY_NAME;
req->rdv_get_by_name.name = name;
SIMIX_request_push();
- return req->rdv_get_by_name.result;
+ return req->rdv_get_by_name.result;*/
+
+ return SIMIX_rdv_get_by_name(name);
}
/**
}
/**
@@
-598,7
+618,8
@@
smx_action_t SIMIX_req_rdv_get_head(smx_rdv_t rdv)
smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
void *src_buff, size_t src_buff_size,
smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
void *src_buff, size_t src_buff_size,
- int (*match_fun)(void *, void *), void *data)
+ int (*match_fun)(void *, void *), void *data,
+ int detached)
{
smx_req_t req = SIMIX_req_mine();
{
smx_req_t req = SIMIX_req_mine();
@@
-612,6
+633,7
@@
smx_action_t SIMIX_req_comm_isend(smx_rdv_t rdv, double task_size, double rate,
req->comm_isend.src_buff_size = src_buff_size;
req->comm_isend.match_fun = match_fun;
req->comm_isend.data = data;
req->comm_isend.src_buff_size = src_buff_size;
req->comm_isend.match_fun = match_fun;
req->comm_isend.data = data;
+ req->comm_isend.detached = detached;
SIMIX_request_push();
return req->comm_isend.result;
SIMIX_request_push();
return req->comm_isend.result;
@@
-637,6
+659,9
@@
smx_action_t SIMIX_req_comm_irecv(smx_rdv_t rdv, void *dst_buff, size_t * dst_bu
void SIMIX_req_comm_destroy(smx_action_t comm)
{
void SIMIX_req_comm_destroy(smx_action_t comm)
{
+ xbt_assert0(comm, "Invalid parameter");
+
+ /* FIXME remove this request type (auto-destroy finished comms) */
smx_req_t req = SIMIX_req_mine();
req->call = REQ_COMM_DESTROY;
smx_req_t req = SIMIX_req_mine();
req->call = REQ_COMM_DESTROY;
@@
-700,6
+725,10
@@
void SIMIX_req_comm_wait(smx_action_t comm, double timeout)
*/
void SIMIX_req_set_category(smx_action_t action, const char *category)
{
*/
void SIMIX_req_set_category(smx_action_t action, const char *category)
{
+ if (category == NULL) {
+ return;
+ }
+
smx_req_t req = SIMIX_req_mine();
req->call = REQ_SET_CATEGORY;
smx_req_t req = SIMIX_req_mine();
req->call = REQ_SET_CATEGORY;
@@
-1035,6
+1064,9
@@
int SIMIX_req_sem_get_capacity(smx_sem_t sem)
SIMIX_request_push();
return req->sem_get_capacity.result;
}
SIMIX_request_push();
return req->sem_get_capacity.result;
}
+/* ************************************************************************** */
-
-
+/** @brief returns a printable string representing the request kind */
+const char *SIMIX_request_name(int kind) {
+ return request_names[kind];
+}