Skip to content

java/Prequest: keep a pointer to the buffer #815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions ompi/mpi/java/java/Comm.java
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ public final Prequest sendInit(Buffer buf, int count,
{
MPI.check();
assertDirectBuffer(buf);
return new Prequest(sendInit(handle, buf, count, type.handle, dest, tag));
return new Prequest(sendInit(handle, buf, count, type.handle, dest, tag), buf);
}

private native long sendInit(
Expand All @@ -794,7 +794,7 @@ public final Prequest bSendInit(Buffer buf, int count,
{
MPI.check();
assertDirectBuffer(buf);
return new Prequest(bSendInit(handle, buf, count, type.handle, dest, tag));
return new Prequest(bSendInit(handle, buf, count, type.handle, dest, tag), buf);
}

private native long bSendInit(
Expand All @@ -819,7 +819,7 @@ public final Prequest sSendInit(Buffer buf, int count,
{
MPI.check();
assertDirectBuffer(buf);
return new Prequest(sSendInit(handle, buf, count, type.handle, dest, tag));
return new Prequest(sSendInit(handle, buf, count, type.handle, dest, tag), buf);
}

private native long sSendInit(
Expand All @@ -844,7 +844,7 @@ public final Prequest rSendInit(Buffer buf, int count,
{
MPI.check();
assertDirectBuffer(buf);
return new Prequest(rSendInit(handle, buf, count, type.handle, dest, tag));
return new Prequest(rSendInit(handle, buf, count, type.handle, dest, tag), buf);
}

private native long rSendInit(
Expand All @@ -869,7 +869,7 @@ public final Prequest recvInit(Buffer buf, int count,
{
MPI.check();
assertDirectBuffer(buf);
return new Prequest(recvInit(handle, buf, count, type.handle, source, tag));
return new Prequest(recvInit(handle, buf, count, type.handle, source, tag), buf);
}

private native long recvInit(
Expand Down
14 changes: 13 additions & 1 deletion ompi/mpi/java/java/Prequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -47,18 +49,28 @@

package mpi;

import java.nio.Buffer;

/**
* Persistent request object.
*/
public final class Prequest extends Request
{
/**
* Buffer used internally by the persistent request
* maintain a pointer to the buffer to ensure it
* cannot be free'd by the garbage collector
*/
private Buffer buffer;

/**
* Constructor used by {@code sendInit}, etc.
* @param handle Handle for the Prequest object
*/
protected Prequest(long handle)
protected Prequest(long handle, Buffer buffer)
{
super(handle);
this.buffer = buffer;
}

/**
Expand Down