|
@@ -39,10 +39,16 @@ extern struct _starpu_mpi_req* _starpu_mpi_irecv_cache_aware(starpu_data_handle_
|
|
|
void _starpu_mpi_treat_ack_receipt_cb(void* _args)
|
|
|
{
|
|
|
struct _starpu_mpi_cp_ack_arg_cb* arg = (struct _starpu_mpi_cp_ack_arg_cb*) _args;
|
|
|
+ int ret;
|
|
|
_STARPU_MPI_DEBUG(3, "ack msg recved id:%d inst:%d\n", arg->msg.checkpoint_id, arg->msg.checkpoint_instance);
|
|
|
- if (_checkpoint_template_digest_ack_reception(arg->msg.checkpoint_id, arg->msg.checkpoint_instance) == 0) {
|
|
|
+ ret = _checkpoint_template_digest_ack_reception(arg->msg.checkpoint_id, arg->msg.checkpoint_instance);
|
|
|
+ if (ret == 0) {
|
|
|
free(arg);
|
|
|
}
|
|
|
+ else if (ret == -1)
|
|
|
+ {
|
|
|
+ STARPU_ABORT_MSG("Could not find CP template, cpid:%d - cpinst:%d\n", arg->msg.checkpoint_id, arg->msg.checkpoint_instance);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void _arg_free(void* _args)
|
|
@@ -52,20 +58,18 @@ void _arg_free(void* _args)
|
|
|
free(arg);
|
|
|
}
|
|
|
|
|
|
-void _starpu_mpi_push_cp_ack_send_cb(void* _args)
|
|
|
+void _starpu_mpi_store_data_and_send_ack_cb(void* _args)
|
|
|
{
|
|
|
struct _starpu_mpi_cp_ack_arg_cb* arg = (struct _starpu_mpi_cp_ack_arg_cb*) _args;
|
|
|
+ if (STARPU_VALUE == arg->type) {
|
|
|
+ // an handle as specificaly been created, no need to copy the data. Call directly the Callback
|
|
|
+ arg->copy_handle = arg->handle;
|
|
|
+ }
|
|
|
+ checkpoint_package_data_add(arg->msg.checkpoint_id, arg->msg.checkpoint_instance, arg->rank, arg->tag, arg->type, arg->copy_handle, arg->count);
|
|
|
_STARPU_MPI_DEBUG(3,"Send ack msg to %d: id=%d inst=%d\n", arg->rank, arg->msg.checkpoint_id, arg->msg.checkpoint_instance);
|
|
|
_ft_service_msg_isend_cb((void*)&arg->msg, sizeof(struct _starpu_mpi_cp_ack_msg), arg->rank, _STARPU_MPI_TAG_CP_ACK, MPI_COMM_WORLD, _arg_free, _args);
|
|
|
}
|
|
|
|
|
|
-void _starpu_mpi_store_data_and_push_cp_ack_send_cb(void* _args)
|
|
|
-{
|
|
|
- struct _starpu_mpi_cp_ack_arg_cb* arg = (struct _starpu_mpi_cp_ack_arg_cb*) _args;
|
|
|
- checkpoint_package_data_add(arg->msg.checkpoint_id, arg->msg.checkpoint_instance, arg->rank, arg->tag, arg->type, arg->copy_handle, arg->count);
|
|
|
- _starpu_mpi_push_cp_ack_send_cb(_args);
|
|
|
-}
|
|
|
-
|
|
|
void _starpu_mpi_push_cp_ack_recv_cb(void* _args)
|
|
|
{
|
|
|
struct _starpu_mpi_cp_ack_arg_cb* arg = (struct _starpu_mpi_cp_ack_arg_cb*) _args;
|
|
@@ -78,36 +82,23 @@ void _starpu_mpi_push_cp_ack_recv_cb(void* _args)
|
|
|
_ft_service_msg_irecv_cb((void*)&arg->msg, sizeof(struct _starpu_mpi_cp_ack_msg), arg->rank, _STARPU_MPI_TAG_CP_ACK, MPI_COMM_WORLD, _starpu_mpi_treat_ack_receipt_cb, _args);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-void _starpu_checkpoint_cached_data_recv_copy_and_ack(void* _arg)
|
|
|
+void _starpu_mpi_cached_push_cp_ack_recv_cb(void* _args)
|
|
|
{
|
|
|
- struct _starpu_mpi_cp_ack_arg_cb* arg = (struct _starpu_mpi_cp_ack_arg_cb*) _arg;
|
|
|
- starpu_data_dup_ro(&arg->copy_handle, arg->handle, 1, _starpu_mpi_store_data_and_push_cp_ack_send_cb, _arg);
|
|
|
-// starpu_data_register_same(&arg->copy_handle, arg->handle);
|
|
|
-// starpu_data_cpy(arg->copy_handle, arg->handle, 1, _starpu_mpi_store_data_and_push_cp_ack_send_cb, _arg);
|
|
|
- starpu_data_release(arg->handle);
|
|
|
+ struct _starpu_mpi_cp_ack_arg_cb* arg = (struct _starpu_mpi_cp_ack_arg_cb*) _args;
|
|
|
+ if (STARPU_R == arg->type)
|
|
|
+ {
|
|
|
+ starpu_data_release(arg->handle);
|
|
|
+ }
|
|
|
+ _STARPU_MPI_DEBUG(3, "Posting ack recv cb from %d\n", arg->rank);
|
|
|
+ _ft_service_msg_irecv_cb((void*)&arg->msg, sizeof(struct _starpu_mpi_cp_ack_msg), arg->rank, _STARPU_MPI_TAG_CP_ACK, MPI_COMM_WORLD, _starpu_mpi_treat_ack_receipt_cb, _args);
|
|
|
}
|
|
|
|
|
|
-void _starpu_checkpoint_data_recv_copy_and_ack(void* _arg)
|
|
|
+void _starpu_data_release_cb(void* _arg)
|
|
|
{
|
|
|
- struct _starpu_mpi_cp_ack_arg_cb* arg = (struct _starpu_mpi_cp_ack_arg_cb*) _arg;
|
|
|
-
|
|
|
- if (STARPU_VALUE == arg->type)
|
|
|
- {
|
|
|
- // an handle as specificaly been created, no need to copy the data. Call directly the Callback
|
|
|
- arg->copy_handle = arg->handle;
|
|
|
- _starpu_mpi_store_data_and_push_cp_ack_send_cb(_arg);
|
|
|
- return;
|
|
|
- }
|
|
|
- else if (STARPU_R == arg->type)
|
|
|
- {
|
|
|
- starpu_data_dup_ro(&arg->copy_handle, arg->handle, 1, _starpu_mpi_store_data_and_push_cp_ack_send_cb, _arg);
|
|
|
-// starpu_data_register_same(&arg->copy_handle, arg->handle);
|
|
|
-// starpu_data_cpy(arg->copy_handle, arg->handle, 1, _starpu_mpi_store_data_and_push_cp_ack_send_cb, _arg);
|
|
|
- return;
|
|
|
- }
|
|
|
+ starpu_data_release(_arg);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
int starpu_mpi_submit_checkpoint_template(starpu_mpi_checkpoint_template_t cp_template)
|
|
|
{
|
|
|
// TODO: For now checkpoint are not taken asynchronously. It will be later, and then we will have to acquire READ permissions to StarPU in order to not have the data potentially corrupted.
|
|
@@ -116,14 +107,9 @@ int starpu_mpi_submit_checkpoint_template(starpu_mpi_checkpoint_template_t cp_te
|
|
|
void* cpy_ptr;
|
|
|
struct _starpu_mpi_checkpoint_template_item* item;
|
|
|
//MPI_Comm comm;
|
|
|
- starpu_pthread_mutex_lock(&cp_template->mutex);
|
|
|
set_pending_checkpoint_template(cp_template);
|
|
|
- STARPU_ASSERT_MSG(cp_template->pending==0, "Can not submit a checkpoint while previous instance has not succeeded.\n");
|
|
|
|
|
|
- cp_template->pending = 1;
|
|
|
- cp_template->cp_template_current_instance++;
|
|
|
- cp_template->remaining_ack_awaited = cp_template->sent_message_number;
|
|
|
- starpu_pthread_mutex_unlock(&cp_template->mutex);
|
|
|
+ checkpoint_template_increment_instance(cp_template);
|
|
|
|
|
|
item = _starpu_mpi_checkpoint_template_get_first_data(cp_template);
|
|
|
|
|
@@ -151,6 +137,7 @@ int starpu_mpi_submit_checkpoint_template(starpu_mpi_checkpoint_template_t cp_te
|
|
|
_STARPU_MPI_DEBUG(0, "Submit CP: sending external data:%d, tag:%ld, to :%d\n", (int)(*(int*)cpy_ptr), arg->tag, arg->rank);
|
|
|
starpu_mpi_isend_detached_prio(*handle, arg->rank, arg->tag, 0, MPI_COMM_WORLD,
|
|
|
&_starpu_mpi_push_cp_ack_recv_cb, (void*)arg);
|
|
|
+ // The callback needs to free the handle specially created for the send, and post ack recv
|
|
|
}
|
|
|
else if (item->backup_of != -1)
|
|
|
{
|
|
@@ -159,7 +146,8 @@ int starpu_mpi_submit_checkpoint_template(starpu_mpi_checkpoint_template_t cp_te
|
|
|
arg->rank = item->backup_of;
|
|
|
_STARPU_MPI_DEBUG(0, "Submit CP: receiving external data tag:%ld, from :%d\n", arg->tag, arg->rank);
|
|
|
starpu_mpi_irecv_detached(*handle, arg->rank, arg->tag, MPI_COMM_WORLD,
|
|
|
- &_starpu_checkpoint_data_recv_copy_and_ack, (void*)arg);
|
|
|
+ &_starpu_mpi_store_data_and_send_ack_cb, (void*)arg);
|
|
|
+ // The callback needs to store the received data and post ack send
|
|
|
}
|
|
|
break;
|
|
|
case STARPU_R:
|
|
@@ -176,7 +164,9 @@ int starpu_mpi_submit_checkpoint_template(starpu_mpi_checkpoint_template_t cp_te
|
|
|
arg->msg.checkpoint_id = cp_template->cp_template_id;
|
|
|
arg->msg.checkpoint_instance = cp_template->cp_template_current_instance;
|
|
|
_starpu_mpi_isend_cache_aware(*handle, item->backupped_by, starpu_mpi_data_get_tag(*handle), MPI_COMM_WORLD, 1, 0, 0,
|
|
|
- &_starpu_mpi_push_cp_ack_recv_cb, (void*)arg, &_starpu_mpi_push_cp_ack_recv_cb, (void*)arg, 1);
|
|
|
+ &_starpu_mpi_push_cp_ack_recv_cb, (void*)arg, &_starpu_mpi_cached_push_cp_ack_recv_cb, (void*)arg, 1);
|
|
|
+ // the callbacks need to post ack recv. The cache one needs to release the handle.
|
|
|
+
|
|
|
}
|
|
|
else if (item->backup_of == starpu_mpi_data_get_rank(*handle))
|
|
|
{
|
|
@@ -190,7 +180,11 @@ int starpu_mpi_submit_checkpoint_template(starpu_mpi_checkpoint_template_t cp_te
|
|
|
arg->msg.checkpoint_id = cp_template->cp_template_id;
|
|
|
arg->msg.checkpoint_instance = cp_template->cp_template_current_instance;
|
|
|
_starpu_mpi_irecv_cache_aware(*handle, starpu_mpi_data_get_rank(*handle), starpu_mpi_data_get_tag(*handle), MPI_COMM_WORLD, 1, 0,
|
|
|
- &_starpu_checkpoint_data_recv_copy_and_ack, (void*)arg, &_starpu_checkpoint_cached_data_recv_copy_and_ack, (void*)arg, 1, 0, 1);
|
|
|
+ NULL, NULL, &_starpu_data_release_cb, (void*)arg->handle, 1, 0, 1);
|
|
|
+ // The callback needs to do nothing. The cached one must release the handle.
|
|
|
+ starpu_data_dup_ro(&arg->copy_handle, arg->handle, 1, NULL, NULL);
|
|
|
+ starpu_data_acquire_cb(arg->copy_handle, STARPU_R, _starpu_mpi_store_data_and_send_ack_cb, arg);
|
|
|
+ // The callback need to store the data and post ack send.
|
|
|
}
|
|
|
break;
|
|
|
}
|