;;
;; 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 communicators
; Include into generated code, but don't parse:
#>
static C_word MPI_comm_p(C_word obj)
{
if (C_immediatep(obj)) {
return C_SCHEME_FALSE;
} else if (C_block_header(obj) == MPI_COMM_TAG)
{
return C_SCHEME_TRUE;
} else {
return C_SCHEME_FALSE;
}
}
static C_word MPI_check_comm (C_word obj)
{
if (C_immediatep(obj))
{
chicken_MPI_exception (MPI_ERR_COMM, 32, "invalid MPI communicator object");
} else if (C_block_header(obj) == MPI_COMM_TAG)
{
return C_SCHEME_UNDEFINED;
} else {
chicken_MPI_exception (MPI_ERR_COMM, 32, "invalid MPI communicator object");
}
}
<#
(define MPI:comm? (foreign-lambda scheme-object "MPI_comm_p" scheme-object))
(define MPI_comm_finalizer
(foreign-safe-lambda* void ((scheme-object comm))
#<
C_word MPI_comm_compare(C_word comm1, C_word comm2)
{
int res;
res = 0;
if ((MPI_comm_p (comm1)) && (MPI_comm_p (comm2)))
{
MPI_Comm_compare(Comm_val(comm1), Comm_val(comm2), &res);
}
if (res == 0)
return C_SCHEME_TRUE;
else
return C_SCHEME_FALSE;
}
<#
(define MPI:comm-equal? (foreign-lambda scheme-object "MPI_comm_compare" scheme-object scheme-object))
(define MPI_comm_split
(foreign-primitive nonnull-c-pointer ((scheme-object comm) (integer color) (integer key))
#<
C_word MPI_get_undefined(void)
{
return C_fix(MPI_UNDEFINED);
}
<#
(define MPI_comm_create
(foreign-primitive nonnull-c-pointer ((scheme-object comm) (scheme-object group))
#<