libcaf.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* Common declarations for all of GNU Fortran libcaf implementations.
  2. Copyright (C) 2011-2015 Free Software Foundation, Inc.
  3. Contributed by Tobias Burnus <burnus@net-b.de>
  4. This file is part of the GNU Fortran Coarray Runtime Library (libcaf).
  5. Libcaf is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3, or (at your option)
  8. any later version.
  9. Libcaf is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. Under Section 7 of GPL version 3, you are granted additional
  14. permissions described in the GCC Runtime Library Exception, version
  15. 3.1, as published by the Free Software Foundation.
  16. You should have received a copy of the GNU General Public License and
  17. a copy of the GCC Runtime Library Exception along with this program;
  18. see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. <http://www.gnu.org/licenses/>. */
  20. #ifndef LIBCAF_H
  21. #define LIBCAF_H
  22. #include <stdbool.h>
  23. #include <stddef.h> /* For size_t. */
  24. #include <stdint.h> /* For int32_t. */
  25. #include "libgfortran.h"
  26. #if 0
  27. #ifndef __GNUC__
  28. #define __attribute__(x)
  29. #define likely(x) (x)
  30. #define unlikely(x) (x)
  31. #else
  32. #define likely(x) __builtin_expect(!!(x), 1)
  33. #define unlikely(x) __builtin_expect(!!(x), 0)
  34. #endif
  35. /* Definitions of the Fortran 2008 standard; need to kept in sync with
  36. ISO_FORTRAN_ENV, cf. libgfortran.h. */
  37. #define STAT_UNLOCKED 0
  38. #define STAT_LOCKED 1
  39. #define STAT_LOCKED_OTHER_IMAGE 2
  40. #define STAT_STOPPED_IMAGE 6000
  41. #endif
  42. /* Describes what type of array we are registerring. Keep in sync with
  43. gcc/fortran/trans.h. */
  44. typedef enum caf_register_t {
  45. CAF_REGTYPE_COARRAY_STATIC,
  46. CAF_REGTYPE_COARRAY_ALLOC,
  47. CAF_REGTYPE_LOCK_STATIC,
  48. CAF_REGTYPE_LOCK_ALLOC,
  49. CAF_REGTYPE_CRITICAL
  50. }
  51. caf_register_t;
  52. typedef void* caf_token_t;
  53. typedef gfc_array_void gfc_descriptor_t;
  54. /* Linked list of static coarrays registered. */
  55. typedef struct caf_static_t {
  56. caf_token_t token;
  57. struct caf_static_t *prev;
  58. }
  59. caf_static_t;
  60. /* When there is a vector subscript in this dimension, nvec == 0, otherwise,
  61. lower_bound, upper_bound, stride contains the bounds relative to the declared
  62. bounds; kind denotes the integer kind of the elements of vector[]. */
  63. typedef struct caf_vector_t {
  64. size_t nvec;
  65. union {
  66. struct {
  67. void *vector;
  68. int kind;
  69. } v;
  70. struct {
  71. ptrdiff_t lower_bound, upper_bound, stride;
  72. } triplet;
  73. } u;
  74. }
  75. caf_vector_t;
  76. void _gfortran_caf_init (int *, char ***);
  77. void _gfortran_caf_finalize (void);
  78. int _gfortran_caf_this_image (int);
  79. int _gfortran_caf_num_images (int, int);
  80. void *_gfortran_caf_register (size_t, caf_register_t, caf_token_t *, int *,
  81. char *, int);
  82. void _gfortran_caf_deregister (caf_token_t *, int *, char *, int);
  83. void _gfortran_caf_sync_all (int *, char *, int);
  84. void _gfortran_caf_sync_memory (int *, char *, int);
  85. void _gfortran_caf_sync_images (int, int[], int *, char *, int);
  86. void _gfortran_caf_error_stop_str (const char *, int32_t)
  87. __attribute__ ((noreturn));
  88. void _gfortran_caf_error_stop (int32_t) __attribute__ ((noreturn));
  89. void _gfortran_caf_co_broadcast (gfc_descriptor_t *, int, int *, char *, int);
  90. void _gfortran_caf_co_sum (gfc_descriptor_t *, int, int *, char *, int);
  91. void _gfortran_caf_co_min (gfc_descriptor_t *, int, int *, char *, int, int);
  92. void _gfortran_caf_co_max (gfc_descriptor_t *, int, int *, char *, int, int);
  93. void _gfortran_caf_co_reduce (gfc_descriptor_t *, void* (*) (void *, void*),
  94. int, int, int *, char *, int, int);
  95. void _gfortran_caf_get (caf_token_t, size_t, int, gfc_descriptor_t *,
  96. caf_vector_t *, gfc_descriptor_t *, int, int, bool);
  97. void _gfortran_caf_send (caf_token_t, size_t, int, gfc_descriptor_t *,
  98. caf_vector_t *, gfc_descriptor_t *, int, int, bool);
  99. void _gfortran_caf_sendget (caf_token_t, size_t, int, gfc_descriptor_t *,
  100. caf_vector_t *, caf_token_t, size_t, int,
  101. gfc_descriptor_t *, caf_vector_t *, int, int, bool);
  102. void _gfortran_caf_atomic_define (caf_token_t, size_t, int, void *, int *,
  103. int, int);
  104. void _gfortran_caf_atomic_ref (caf_token_t, size_t, int, void *, int *,
  105. int, int);
  106. void _gfortran_caf_atomic_cas (caf_token_t, size_t, int, void *, void *,
  107. void *, int *, int, int);
  108. void _gfortran_caf_atomic_op (int, caf_token_t, size_t, int, void *, void *,
  109. int *, int, int);
  110. void _gfortran_caf_lock (caf_token_t, size_t, int, int *, int *, char *, int);
  111. void _gfortran_caf_unlock (caf_token_t, size_t, int, int *, char *, int);
  112. #endif /* LIBCAF_H */