123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- /* StarPU --- Runtime system for heterogeneous multicore architectures.
- *
- * Copyright (C) 2014-2020 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
- *
- * StarPU is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or (at
- * your option) any later version.
- *
- * StarPU is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * See the GNU Lesser General Public License in COPYING.LGPL for more details.
- */
- #ifndef FT_STARPU_STARPU_MPI_CHECKPOINT_H
- #define FT_STARPU_STARPU_MPI_CHECKPOINT_H
- #include <starpu_mpi.h>
- #include <common/list.h>
- #include "starpu_mpi_private.h"
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- LIST_TYPE(_starpu_mpi_checkpoint_template_item,
- int type;
- void* ptr;
- int count;
- int backup_rank;
- int backup_of;
- );
- struct _starpu_mpi_checkpoint_template{
- struct _starpu_mpi_checkpoint_template_item_list list;
- int size;
- int cp_template_id;
- int pending;
- int frozen;
- starpu_pthread_mutex_t mutex;
- starpu_sem_t completion_sem;
- };
- static inline struct _starpu_mpi_checkpoint_template_item* _starpu_mpi_checkpoint_template_item_create(int type, void* ptr, int count, int backup_rank, int backup_of)
- {
- struct _starpu_mpi_checkpoint_template_item* item;
- _STARPU_MPI_CALLOC(item, 1, sizeof(struct _starpu_mpi_checkpoint_template_item));
- item->type = type;
- item->ptr = ptr;
- item->count = count;
- item->backup_rank = backup_rank;
- item->backup_of = backup_of;
- return item;
- }
- static inline starpu_mpi_checkpoint_template_t _starpu_mpi_checkpoint_template_new(int cp_id)
- {
- starpu_mpi_checkpoint_template_t _cp_template;
- _STARPU_MPI_CALLOC(_cp_template, 1, sizeof(struct _starpu_mpi_checkpoint_template));
- _cp_template->cp_template_id = cp_id;
- starpu_pthread_mutex_init(&_cp_template->mutex, NULL);
- return _cp_template;
- }
- static inline int _starpu_mpi_checkpoint_template_add_data(starpu_mpi_checkpoint_template_t cp_template, int type, void* ptr, int count, int backup_rank, int backup_of)
- {
- STARPU_ASSERT_MSG(!cp_template->frozen, "It is not possible to modify registered checkpoint template.\n");
- struct _starpu_mpi_checkpoint_template_item* item;
- item = _starpu_mpi_checkpoint_template_item_create(type, ptr, count, backup_rank, backup_of);
- _starpu_mpi_checkpoint_template_item_list_push_back(&cp_template->list, item);
- return 0;
- }
- static inline int _starpu_mpi_checkpoint_template_freeze(starpu_mpi_checkpoint_template_t _cp_template)
- {
- _cp_template->frozen = 1;
- _cp_template->size = _starpu_mpi_checkpoint_template_item_list_size(&_cp_template->list);
- starpu_sem_init(&_cp_template->completion_sem, 0, _cp_template->size-1);
- return _cp_template->size;
- }
- static inline struct _starpu_mpi_checkpoint_template_item* _starpu_mpi_checkpoint_template_get_first_data(starpu_mpi_checkpoint_template_t template)
- {
- return _starpu_mpi_checkpoint_template_item_list_front(&template->list);
- }
- static inline struct _starpu_mpi_checkpoint_template_item* _starpu_mpi_checkpoint_template_get_next_data(starpu_mpi_checkpoint_template_t template STARPU_ATTRIBUTE_UNUSED, struct _starpu_mpi_checkpoint_template_item* ref_data)
- {
- return _starpu_mpi_checkpoint_template_item_list_next(ref_data);
- }
- static inline struct _starpu_mpi_checkpoint_template_item* _starpu_mpi_checkpoint_template_end(starpu_mpi_checkpoint_template_t template STARPU_ATTRIBUTE_UNUSED)
- {
- return NULL;
- }
- int _starpu_mpi_checkpoint_turn_on(void);
- // For test purpose
- int _starpu_mpi_checkpoint_template_print(starpu_mpi_checkpoint_template_t cp_template);
- #ifdef __cplusplus
- }
- #endif
- #endif //FT_STARPU_STARPU_MPI_CHECKPOINT_H
|