Hi Saliya,

In the in the previous versions of the library, MAXLOC and MINLOC were implemented in Java and it was possible to use Java int arrays. But now the implementation is native and you can not use Java int because on some platforms the int size (in the C side) may be different.

You must use the struct 'mpi.Int2' as you can see in your corrected example.

Regards,
Oscar

From: Saliya Ekanayake <esal...@gmail.com<mailto:esal...@gmail.com>>
Subject: [OMPI devel] Bug in MPI.MINLOC with Java binding
Date: November 11, 2013 3:35:23 PM EST
To: <de...@open-mpi.org<mailto:de...@open-mpi.org>>
Reply-To: Open MPI Developers <de...@open-mpi.org<mailto:de...@open-mpi.org>>

Hi,

I've been using nightly tarball openmpi-1.9a1r28919 with Java binding and it had a bug in its MINLOC implementation (Minloc.java). Essentially, the following line,

out_array [outdisp + 1] = in_array [outdisp + 1] ;

should be changed to

out_array [outdisp + 1] = in_array [indisp + 1] ;

The same should be done for MAXLOC (Maxloc.java) implementation as well. I tested with the change and both MINLOC and MAXLOC worked as expected afterwards.

However, these files are no longer available in the latest trunk and it seems the API for collective operations have changed as well. Still MINLOC (and MAXLOC) does not work as expected. I've attached a sample code to reproduce the issue and an output from it (for MINLOC).

I am running on 64bit Ubuntu 12.04.

Any suggestions?

Thank you in advance,
Saliya

--
Saliya Ekanayake esal...@gmail.com<mailto:esal...@gmail.com>
http://saliya.org<http://saliya.org/>
_______________________________________________
devel mailing list
de...@open-mpi.org<mailto:de...@open-mpi.org>
http://www.open-mpi.org/mailman/listinfo.cgi/devel


--
Jeff Squyres
jsquy...@cisco.com<mailto:jsquy...@cisco.com>
For corporate legal information go to: http://www.cisco.com/web/about/doing_business/legal/cri/





----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
import mpi.*;
import java.nio.*;

public class MinlocTester
{
public static void main(String[] args) throws MPIException
{
    MPI.Init(args);
    int me = MPI.COMM_WORLD.getRank();

    // Create an array with 5 random integers in INT2 contiguous format
    int count = 5;
    ByteBuffer in = MPI.newByteBuffer(count * MPI.INT2.getExtent());

    for(int i = 0; i < count; i++)
    {
        Int2.Data d = MPI.int2.getData(in, i);
        d.putValue((int)(Math.random() * count * 10));
        d.putIndex(me);
    }

    // Print my array
    System.out.println("rank: " + me + " " + toString(in, count));

    // Create an array to receive min values and locations in INT2 format
    ByteBuffer out = MPI.newByteBuffer(count * MPI.INT2.getExtent());
    MPI.COMM_WORLD.reduce(in, out, count, MPI.INT2, MPI.MINLOC, 0);

    if(me == 0)
    {
        // Print received array on root
        System.out.println("rank: " + me + " out " + toString(out, count));
    }

    MPI.Finalize();
}

private static String toString(ByteBuffer buf, int count) throws MPIException
{
    StringBuilder sb = new StringBuilder();
    
    for(int i = 0; i < count; i++)
    {
        Int2.Data d = MPI.int2.getData(buf, i);
        sb.append("("+ d.getValue() +","+ d.getIndex() +") ");
    }

    return sb.toString();
}

} // MinlocTester2

Reply via email to