Skip to content
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

Support for RDMA Atomics + Support for user-defined initiator and responder resources on connect/accept #51

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

TaranovK
Copy link

Hi,

The following changes add:

  • RDMA Atomics
  • RDMAConnParam which allows to set atomic resources for initiator and responder

For RDMA atomics I followed implementation of NatRdma and made similar implementation of NatAtomic. Depending on opcode, the writeBack of NatIbvSendWR will append Rdma or Atomic data.
I have also implemented a simple test in com.ibm.disni.examples.AtomicServer and com.ibm.disni.examples.AtomicClient.

For the second change I added extra functions in JNI to connect and accept using all fields of RdmaConnParam. Therefore, the JNI disni library supports both old and new way of establishing connections. In addition, I fixed other parts of the code to support custom RdmaConnParam instead of the default one with zeros for initiator and responder depths.

Cheers,
Konstantin

Copy link
Contributor

@PepperJo PepperJo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request! It generally looks good to me, however I don't like introducing a new connect and accept call (see inline comments).

* Method: _connectV2
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_com_ibm_disni_verbs_impl_NativeDispatcher__1connectV2(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the idea of multiple connect implementations. Why not only keep V2 and expose query_device to Java. This solves multiple problems at once: 1) setting initiator/responder resource without knowing what the max are 2) two implementations of the same function

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. However, since the libdisni is shipped separately, it may force some developers to recompile their java code which uses the library.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should be ok. Developers can always choose to use an old version of the library if needed.

* Method: _acceptV2
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_com_ibm_disni_verbs_impl_NativeDispatcher__1acceptV2(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment to connectV2

src/main/java/com/ibm/disni/verbs/impl/RdmaCmNat.java Outdated Show resolved Hide resolved
connParam.getRnr_retry_count(), connParam.getPrivate_data(), connParam.getPrivate_data_len());

MemBuf memBuf = memAlloc.allocate(connParam.CSIZE);
connParam.writeBack(memBuf.getBuffer());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong indentation

@@ -76,6 +76,12 @@ public void runRDMA() throws Exception {
//create a EndpointGroup. The RdmaActiveEndpointGroup contains CQ processing and delivers CQ event to the endpoint.dispatchCqEvent() method.
endpointGroup = new RdmaActiveEndpointGroup<CustomClientEndpoint>(1000, false, 128, 4, 128);
endpointGroup.init(this);

RdmaConnParam connParam = new RdmaConnParam();
connParam.setResponder_resources((byte) 16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use query_device to set initiator/responder resources (see connectV2 comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I did not check that Disni did not implement it. I usually check the params manually using ibv_devinfo -v. I can add it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the new query_device function here? Otherwise this code will not work on device where responder or initiator depth is less than 16.

/*
* DiSNI: Direct Storage and Networking Interface
*
* Author: Patrick Stuedi <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously, Patrick is not the author of this file so please remove him and add yourself. Also please remove the IBM copyright of this file (I assume you are not an IBM employee)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. it was copy-pasted based implementation. Do I need to include his name though, as 99% of the code there is his?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree if that is the case keep his name.

/*
* DiSNI: Direct Storage and Networking Interface
*
* Author: Patrick Stuedi <[email protected]>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above (change author, remove copyright)

Copy link
Contributor

@PepperJo PepperJo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong byte format of RdmaConnParam

buffer.put(retry_count);
buffer.put(rnr_retry_count);
buffer.put(srq);
buffer.put((byte)0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cq_num is u32 not u8, so this should be putInt(0)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I do not agree. Actually, buffer.put((byte)0); is a padding. cq_num field is 8 byte aligned. To add cq_num the code should be: buffer.put(srq); buffer.put((byte)0); buffer.putInt(cq_num);
I did not add cq_num as it is ignored anyway and does not cause any problems.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@TaranovK
Copy link
Author

TaranovK commented Apr 5, 2020

Hey, I have applied the suggested changes, but the one with removing old connect/accept.

@TaranovK TaranovK requested a review from PepperJo April 5, 2020 15:57
* Signature: (J)I
*/
JNIEXPORT jint JNICALL
Java_com_ibm_disni_verbs_impl_NativeDispatcher__1queryMaxResponderResources(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not what I had in mind. I would like to be able to get all device attributes in Java. Otherwise we will be adding new JNI functions for every member of the struct along the way.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. it was just more work.

* Signature: (J)I
*/
JNIEXPORT jint JNICALL
Java_com_ibm_disni_verbs_impl_NativeDispatcher__1queryMaxInitiatorDepth(JNIEnv *env,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment queryMaxResponderResources

@TaranovK TaranovK requested a review from PepperJo April 6, 2020 15:56
Copy link
Contributor

@PepperJo PepperJo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes. It generally looks good. I just have a few comments:
I still believe we should merge the two JNI connect and accept functions. We can keep the upper level DiSNi API consistent by setting max responder/initiator depth when no connection parameters are set.
Please also update the native library version we use to check for compatibility

@@ -76,6 +76,12 @@ public void runRDMA() throws Exception {
//create a EndpointGroup. The RdmaActiveEndpointGroup contains CQ processing and delivers CQ event to the endpoint.dispatchCqEvent() method.
endpointGroup = new RdmaActiveEndpointGroup<CustomClientEndpoint>(1000, false, 128, 4, 128);
endpointGroup.init(this);

RdmaConnParam connParam = new RdmaConnParam();
connParam.setResponder_resources((byte) 16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the new query_device function here? Otherwise this code will not work on device where responder or initiator depth is less than 16.

@@ -58,6 +58,11 @@ public ReadClient(String host, int port, int size, int loop) throws IOException{
private void run() throws Exception {
System.out.println("ReadClient, size " + size + ", loop " + loop);

RdmaConnParam connParam = new RdmaConnParam();
connParam.setResponder_resources((byte) 0);
connParam.setInitiator_depth((byte) 16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query_device (see other comment)

@@ -57,6 +57,11 @@ public ReadServer(String host, int port, int size, int loop) throws IOException{
private void run() throws Exception {
System.out.println("ReadServer, size " + size + ", loop " + loop);

RdmaConnParam connParam = new RdmaConnParam();
connParam.setResponder_resources((byte) 16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query_device (see other comment)


RdmaConnParam connParam = new RdmaConnParam();
connParam.setResponder_resources((byte) 0);
connParam.setInitiator_depth((byte) 16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query_device (see other comment)

@@ -49,6 +49,12 @@ public void run() throws Exception {
//create a EndpointGroup. The RdmaActiveEndpointGroup contains CQ processing and delivers CQ event to the endpoint.dispatchCqEvent() method.
endpointGroup = new RdmaActiveEndpointGroup<CustomServerEndpoint>(1000, false, 128, 4, 128);
endpointGroup.init(this);

RdmaConnParam connParam = new RdmaConnParam();
connParam.setResponder_resources((byte) 16);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

query_device (see other comment)

@TaranovK
Copy link
Author

Ok. I pushed the changes.

Regarding having single accept vs. having 2 accepts in JNI. I do not think it is a good idea to keep only one call and lose back-compatibility. However, I respect your will to have a single call in the master. You are free to modify my changes and remove the second call before merging the pull request.

For my personal use I need to be back-compatible and I will simply keep using my version.

@TaranovK TaranovK requested a review from PepperJo April 21, 2020 11:28
@PepperJo
Copy link
Contributor

Can you please explain the use case where you need this backwards compatibility?
Do you need to run the same user library with older Java code, why not compile the old library seperatly for that code? What restricts you from updating the old code?
I'm just trying to understand if there are real usecases that I don't see where this is a problem.

@TaranovK
Copy link
Author

TaranovK commented Apr 22, 2020

The problem is that libdisini.so is not included in disni.jar and has to be installed separately.
Therefore, if I install the new Disni and new libdisni all my old java code will not work as an old connect function is not in the shared libdisini.so. Sure, I can have different LD_LIBRARY_PATH for old and new applications, but it sounds cumbersome.

@PepperJo
Copy link
Contributor

If we would "include" libdisni.so in the disni.jar like proposed here: #17
Would that solve your problem with the library versions?

@TaranovK
Copy link
Author

Yes, it would.

@patrickstuedi
Copy link
Member

I haven't read all the comments, and I'm fine with whatever the outcome is related to the connect/accept changes. As for including libdisni.so in disni.jar, that's something we've discussed many times and my opinion remains the same, let's not include shared libraries with the jar. For the time being, increment the version of libdisni after your changes, and similarly make sure in NativeDispatcher you increment the version of libdisni that is required.

@TaranovK
Copy link
Author

TaranovK commented Jun 9, 2020

@patrickstuedi I want to make sure that I understood you correctly. Do you propose to have only the new accept/connect and lose back compatibility? Or are you fine with having both old and new accept/connect in the libdisni.so?

@patrickstuedi
Copy link
Member

I still need to look at the accept/connect changes in more detail, I haven't so far. But keeping an old and new version at the same time doesn't sound too appealing. I'm not so worried about backward compatibility if the changes are required and can be combined with a version bump.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants