;; ;; Chicken MPI interface. Based on the Caml/MPI interface by Xavier ;; Leroy. ;; ;; Copyright 2007-2015 Ivan Raikov. ;; ;; This program is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation, either version 3 of the ;; License, or (at your option) any later version. ;; ;; This program 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 ;; General Public License for more details. ;; ;; A full copy of the GPL license can be found at ;; . ;; ;; Handling of communication groups ; Include into generated code, but don't parse: #> static C_word MPI_group_p(C_word obj) { if (C_immediatep(obj)) { return C_SCHEME_FALSE; } else if (C_block_header(obj) == MPI_GROUP_TAG) { return C_SCHEME_TRUE; } else { return C_SCHEME_FALSE; } } static C_word MPI_check_group (C_word obj) { if (C_immediatep(obj)) { chicken_MPI_exception (MPI_ERR_COMM, 32, "invalid MPI group object"); } else if (C_block_header(obj) == MPI_GROUP_TAG) { return C_SCHEME_UNDEFINED; } else { chicken_MPI_exception (MPI_ERR_COMM, 32, "invalid MPI group object"); } } <# (define MPI:group? (foreign-lambda scheme-object "MPI_group_p" scheme-object)) (define MPI_alloc_group (foreign-primitive scheme-object ((nonnull-c-pointer group)) #< static void MPI_extract_ranges (C_word ranges, /*out*/ int * num, /*out*/ int * exranges) { int i, nranges; C_word range; C_i_check_vector (ranges); nranges = C_unfix(C_i_vector_length (ranges)); for (i = 0; i < nranges; i++) { range = C_i_vector_ref (ranges, C_fix(i)); exranges[(3*i)+0] = C_num_to_int(C_u_i_s32vector_ref(range, C_fix(0))); exranges[(3*i)+1] = C_num_to_int(C_u_i_s32vector_ref(range, C_fix(1))); exranges[(3*i)+2] = C_num_to_int(C_u_i_s32vector_ref(range, C_fix(2))); } } <# (define MPI_group_range_incl (foreign-primitive nonnull-c-pointer ((scheme-object group) (scheme-object ranges) (s32vector exranges)) #<