|
@@ -16,18 +16,24 @@
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
+#include <stdlib.h>
|
|
|
#include <common/utils.h>
|
|
|
|
|
|
#include <starpu_mpi_checkpoint.h>
|
|
|
+#include <sys/param.h>
|
|
|
|
|
|
-int _starpu_mpi_checkpoint_template_register(starpu_mpi_checkpoint_template*
|
|
|
-cp_template, va_list varg_list)
|
|
|
+#define MAX_CP_TEMPLATE_NUMBER 32
|
|
|
+
|
|
|
+starpu_pthread_mutex_t cp_template_mutex;
|
|
|
+starpu_mpi_checkpoint_template cp_template_array[MAX_CP_TEMPLATE_NUMBER];
|
|
|
+int cp_template_number = 0;
|
|
|
+
|
|
|
+int _starpu_mpi_checkpoint_template_register(starpu_mpi_checkpoint_template* cp_template, int cp_id, va_list varg_list)
|
|
|
{
|
|
|
int i = 0;
|
|
|
int arg_type;
|
|
|
|
|
|
- starpu_mpi_checkpoint_template _cp_template;
|
|
|
- _STARPU_MALLOC(_cp_template, sizeof(struct _starpu_mpi_checkpoint_template));
|
|
|
+ starpu_mpi_checkpoint_template _cp_template = _starpu_mpi_checkpoint_create();
|
|
|
|
|
|
va_list varg_list_copy;
|
|
|
va_copy(varg_list_copy, varg_list);
|
|
@@ -46,20 +52,23 @@ cp_template, va_list varg_list)
|
|
|
}
|
|
|
else if (arg_type==STARPU_R)
|
|
|
{
|
|
|
- _cp_template->items[i].type = STARPU_R;
|
|
|
- _cp_template->items[i].ptr = va_arg(varg_list_copy, void*);
|
|
|
+ _cp_template->items[i].type = STARPU_R;
|
|
|
+ _cp_template->items[i].ptr = va_arg(varg_list_copy, void*);
|
|
|
_cp_template->items[i].backup_rank = va_arg(varg_list_copy, int);
|
|
|
}
|
|
|
else if (arg_type==STARPU_VALUE)
|
|
|
{
|
|
|
- _cp_template->items[i].type = STARPU_VALUE;
|
|
|
- _cp_template->items[i].ptr = va_arg(varg_list_copy,void*);
|
|
|
- _cp_template->items[i].count = va_arg(varg_list_copy, int);
|
|
|
+ _cp_template->items[i].type = STARPU_VALUE;
|
|
|
+ _cp_template->items[i].ptr = va_arg(varg_list_copy,void*);
|
|
|
+ _cp_template->items[i].count = va_arg(varg_list_copy, int);
|
|
|
_cp_template->items[i].backup_rank = va_arg(varg_list_copy, int);
|
|
|
}
|
|
|
else if (arg_type==STARPU_DATA_ARRAY)
|
|
|
{
|
|
|
-
|
|
|
+ _cp_template->items[i].type = STARPU_DATA_ARRAY;
|
|
|
+ _cp_template->items[i].ptr = va_arg(varg_list_copy,void*);
|
|
|
+ _cp_template->items[i].count = va_arg(varg_list_copy, int);
|
|
|
+ _cp_template->items[i].backup_rank = va_arg(varg_list_copy, int);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -71,33 +80,62 @@ cp_template, va_list varg_list)
|
|
|
va_end(varg_list_copy);
|
|
|
|
|
|
_cp_template->size = i;
|
|
|
- _cp_template->checkpoint_id = 50909;
|
|
|
+ starpu_sem_init(&_cp_template->completion_sem, 0, _cp_template->size-1);
|
|
|
+ _cp_template->cp_template_id = cp_id;
|
|
|
+
|
|
|
+
|
|
|
|
|
|
*cp_template = _cp_template;
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-int starpu_mpi_checkpoint_template_register(starpu_mpi_checkpoint_template* cp_template, ...) {
|
|
|
+int starpu_mpi_checkpoint_template_register(starpu_mpi_checkpoint_template* cp_template, int cp_id, ...)
|
|
|
+{
|
|
|
va_list varg_list;
|
|
|
- va_start(varg_list, cp_template);
|
|
|
- int ret = _starpu_mpi_checkpoint_template_register(cp_template, varg_list);
|
|
|
+ va_start(varg_list, cp_id);
|
|
|
+ int ret = _starpu_mpi_checkpoint_template_register(cp_template, cp_id, varg_list);
|
|
|
va_end(varg_list);
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-int starpu_mpi_checkpoint_template_print(starpu_mpi_checkpoint_template cp_template) {
|
|
|
+// For test purpose
|
|
|
+int _starpu_mpi_checkpoint_template_print(starpu_mpi_checkpoint_template cp_template)
|
|
|
+{
|
|
|
int val;
|
|
|
- for (int i=0 ; i< cp_template->size ; i++) {
|
|
|
+ for (int i=0 ; i< cp_template->size ; i++)
|
|
|
+ {
|
|
|
fprintf(stderr,"Item %2d: ", i);
|
|
|
- if (cp_template->items[i].type == STARPU_VALUE) {
|
|
|
+ if (cp_template->items[i].type == STARPU_VALUE)
|
|
|
+ {
|
|
|
printf("STARPU_VALUE - Value=%d\n", (*(int *)(cp_template->items[i].ptr)));
|
|
|
- } else if (cp_template->items[i].type == STARPU_R) {
|
|
|
+ }
|
|
|
+ else if (cp_template->items[i].type == STARPU_R)
|
|
|
+ {
|
|
|
val = *(int*)starpu_data_handle_to_pointer(*(starpu_data_handle_t*)(cp_template->items[i].ptr), 0);
|
|
|
printf("STARPU_R - Value=%d\n", val);
|
|
|
- } else {
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (cp_template->items[i].type == STARPU_DATA_ARRAY)
|
|
|
+ {
|
|
|
+ fprintf(stderr, "STARPU_DATA_ARRAY - Multiple values: %d", *(int*)starpu_data_handle_to_pointer(*((starpu_data_handle_t*)cp_template->items[i].ptr), 0));
|
|
|
+
|
|
|
+ for (int j=1 ; j<MIN(cp_template->items[i].count, 5) ; j++)
|
|
|
+ {
|
|
|
+ fprintf(stderr, ", %d", *(int*)starpu_data_handle_to_pointer(((starpu_data_handle_t*)cp_template->items[i].ptr)[j], 0)); //j*sizeof(starpu_data_handle_t)
|
|
|
+ }
|
|
|
+ fprintf(stderr, "...\n");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
printf("Unrecognized type.\n");
|
|
|
}
|
|
|
}
|
|
|
return 0;
|
|
|
+}
|
|
|
+
|
|
|
+int _starpu_mpi_checkpoint_turn_on(void)
|
|
|
+{
|
|
|
+ starpu_pthread_mutex_init(&cp_template_mutex, NULL);
|
|
|
+ return 0;
|
|
|
}
|