Commit 38d96972 authored by Anthony Chan's avatar Anthony Chan
Browse files

[svn-r5676] fixed reduce_local.c and added fortran version, reducelocalf.f,...

[svn-r5676] fixed reduce_local.c and added fortran version, reducelocalf.f, and added these tests into testlist.  Resolving req#798.
parent 23d59338
......@@ -52,7 +52,7 @@ int main( int argc, char *argv[] )
inoutbuf = malloc(sizeof(int) * MAX_BUF_ELEMENTS);
for (count = 0; count < MAX_BUF_ELEMENTS; count = (count*2)+1) {
for (count = 1; count < MAX_BUF_ELEMENTS; count *= 2) {
for (i = 0; i < count; ++i) {
inbuf[i] = i;
inoutbuf[i] = i;
......@@ -68,7 +68,7 @@ int main( int argc, char *argv[] )
/* make sure that user-define ops work too */
MPI_Op_create(&user_op, 0/*!commute*/, &uop);
for (count = 0; count < MAX_BUF_ELEMENTS; count = (count*2)+1) {
for (count = 1; count < MAX_BUF_ELEMENTS; count *= 2) {
for (i = 0; i < count; ++i) {
inbuf[i] = i;
inoutbuf[i] = i;
......
......@@ -5,9 +5,9 @@ allred3 10
allred4 4
reduce 5
reduce 10
reduce_local 2
red3 10
red4 10
reduce_local 1
alltoall1 8
alltoallv 10
alltoallv0 10
......
......@@ -8,6 +8,7 @@ alltoallwf_SOURCES = alltoallwf.f
inplacef_SOURCES = inplacef.f
allredint8f_SOURCES = allredint8f.f
allredopttf_SOURCES = allredopttf.f
reducelocalf_SOURCES = reducelocalf.f
testing:
../../runtests -srcdir=$(srcdir) -tests=testlist \
......
C -*- Mode: Fortran; -*-
C
C (C) 2009 by Argonne National Laboratory.
C See COPYRIGHT in top-level directory.
C
C
C Test Fortran MPI_Reduce_local with MPI_OP_SUM and with user-defined operation.
C
subroutine user_op( invec, outvec, count, datatype )
implicit none
include 'mpif.h'
integer invec(*), outvec(*)
integer count, datatype
integer ii
if (datatype .ne. MPI_INTEGER) then
write(6,*) 'Invalid datatype passed to user_op()'
return
endif
do ii=1, count
outvec(ii) = invec(ii) * 2 + outvec(ii)
enddo
end
program main
implicit none
include 'mpif.h'
integer max_buf_size
parameter (max_buf_size=65000)
integer vin(max_buf_size), vout(max_buf_size)
external user_op
integer ierr, errs
integer count, myop
integer ii, size
integer comm
errs = 0
call mtest_init(ierr)
count = 1
do while (count .le. max_buf_size )
do ii = 1,count
vin(ii) = ii
vout(ii) = ii
enddo
call mpi_reduce_local( vin, vout, count,
& MPI_INTEGER, MPI_SUM, ierr )
C Check if the result is correct
do ii = 1,count
if ( vin(ii) .ne. ii ) then
errs = errs + 1
endif
if ( vout(ii) .ne. 2*ii ) then
errs = errs + 1
endif
enddo
count = count + count
enddo
call mpi_op_create( user_op, .false., myop, ierr )
count = 1
do while (count .le. max_buf_size)
do ii = 1, count
vin(ii) = ii
vout(ii) = ii
enddo
call mpi_reduce_Local( vin, vout, count,
& MPI_INTEGER, myop, ierr )
C Check if the result is correct
do ii = 1, count
if ( vin(ii) .ne. ii ) then
errs = errs + 1
endif
if ( vout(ii) .ne. 3*ii ) then
errs = errs + 1
endif
enddo
count = count + count
enddo
call mpi_op_free( myop, ierr )
call mtest_finalize(errs)
call mpi_finalize(ierr)
end
......@@ -2,3 +2,4 @@ uallreducef 4
exscanf 5
alltoallwf 7
inplacef 4
reducelocalf 2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment