From 7b4cd0d256df0ddbb9fd10f7e11f6eecb8020f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Fri, 6 Feb 2015 18:08:06 +0000 Subject: [PATCH] patch by Fab. Riguzzi to fix MPI interface --- library/lammpi/prologterms2c.c | 6 +----- library/lammpi/yap_mpi.c | 8 +++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/library/lammpi/prologterms2c.c b/library/lammpi/prologterms2c.c index 6a1740940..6cfc4d07d 100644 --- a/library/lammpi/prologterms2c.c +++ b/library/lammpi/prologterms2c.c @@ -102,11 +102,7 @@ void change_buffer_size(const size_t newsize) { if ( BUFFER_SIZE>=BLOCK_SIZE && BUFFER_SIZE>=newsize) return; - if (BUFFER_PTR) { - free(BUFFER_PTR); - } - BUFFER_PTR = (char*)malloc(newsize); - if( BUFFER_PTR == NULL ) { + if (realloc( BUFFER_PTR, newsize) == NULL) { YAP_Error(0,0,"Prolog2Term: Out of memory.\n"); #ifdef MPI MPI_Finalize(); diff --git a/library/lammpi/yap_mpi.c b/library/lammpi/yap_mpi.c index 51c4fe4c5..6c122cf5c 100644 --- a/library/lammpi/yap_mpi.c +++ b/library/lammpi/yap_mpi.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2004,2005,2006 (Nuno A. Fonseca) + Copyright (C) 2004,2005,2006 (Nuno A. Fonseca) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -41,9 +41,7 @@ Comments: YAP interface to LAM/MPI #include "prologterms2c.h" -#ifndef _yap_c_interface_h #include -#endif #include "hash.h" @@ -976,7 +974,7 @@ mpi_gc(void) { RETURN(TRUE); } -int BLOCK_SIZE=4*1024; +size_t BLOCK_SIZE=4*1024; static int mpi_default_buffer_size(void) @@ -1022,7 +1020,7 @@ init_mpi(void) { YAP_UserCPredicate( "mpi_wait", mpi_wait,2); // mpi_wait(+Handle,-Status). YAP_UserCPredicate( "mpi_wait_recv", mpi_wait_recv,3); // mpi_wait_recv(+Handle,-Status,-Data). YAP_UserCPredicate( "mpi_test", mpi_test,2); // mpi_test(+Handle,-Status). - YAP_UserCPredicate( "mpi_test_rcv", mpi_test_recv,3); // mpi_test(+Handle,-Status,-Data). + YAP_UserCPredicate( "mpi_test_recv", mpi_test_recv,3); // mpi_test(+Handle,-Status,-Data). YAP_UserCPredicate( "mpi_bcast", mpi_bcast,2); // mpi_bcast(Root,Term) YAP_UserCPredicate( "mpi_bcast2", mpi_bcast2,2); // mpi_bcast2(Root,Term) YAP_UserCPredicate( "mpi_bcast3", mpi_bcast3,3); // mpi_bcast3(Root,Term,Tag)