-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into topic/rdesc-obj-str
- Loading branch information
Showing
44 changed files
with
1,422 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright (C) 2021, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
* See file LICENSE for terms. | ||
*/ | ||
|
||
package ucx | ||
|
||
// #include <ucp/api/ucp.h> | ||
import "C" | ||
|
||
type UcpConnectionRequest struct { | ||
connRequest C.ucp_conn_request_h | ||
listener C.ucp_listener_h | ||
} | ||
|
||
func (c *UcpConnectionRequest) Reject() error { | ||
if status := C.ucp_listener_reject(c.listener, c.connRequest); status != C.UCS_OK { | ||
return NewUcxError(status) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2021, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
* See file LICENSE for terms. | ||
*/ | ||
|
||
package ucx | ||
|
||
// #include <ucp/api/ucp.h> | ||
import "C" | ||
import "net" | ||
|
||
type UcpListener struct { | ||
listener C.ucp_listener_h | ||
connHandlerId uint64 | ||
} | ||
|
||
// Needed to call connHandler.Reject() rather than listener.Reject(connHandler) | ||
var connHandles2Listener = make(map[uint64]C.ucp_listener_h) | ||
|
||
type UcpListenerAttributes struct { | ||
Address *net.TCPAddr | ||
} | ||
|
||
func (l *UcpListener) Close() { | ||
C.ucp_listener_destroy(l.listener) | ||
deregister(l.connHandlerId) | ||
delete(connHandles2Listener, l.connHandlerId) | ||
} | ||
|
||
func (l *UcpListener) Query(attrs ...UcpListenerAttribute) (*UcpListenerAttributes, error) { | ||
var listenerAttr C.ucp_listener_attr_t | ||
|
||
for _, attr := range attrs { | ||
listenerAttr.field_mask |= C.ulong(attr) | ||
} | ||
|
||
if status := C.ucp_listener_query(l.listener, &listenerAttr); status != C.UCS_OK { | ||
return nil, NewUcxError(status) | ||
} | ||
|
||
result := &UcpListenerAttributes{} | ||
|
||
for _, attr := range attrs { | ||
switch attr { | ||
case UCP_LISTENER_ATTR_FIELD_SOCKADDR: | ||
result.Address = toTcpAddr(&listenerAttr.sockaddr) | ||
} | ||
} | ||
return result, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2021, NVIDIA CORPORATION & AFFILIATES. ALL RIGHTS RESERVED. | ||
* See file LICENSE for terms. | ||
*/ | ||
|
||
package ucx | ||
|
||
// #include <ucp/api/ucp.h> | ||
// #include "goucx.h" | ||
import "C" | ||
import ( | ||
"net" | ||
"runtime" | ||
"unsafe" | ||
) | ||
|
||
// Tuning parameters for the UCP listener. | ||
type UcpListenerParams struct { | ||
params C.ucp_listener_params_t | ||
connHandlerId uint64 | ||
} | ||
|
||
//export ucxgo_completeConnHandler | ||
func ucxgo_completeConnHandler(connRequest C.ucp_conn_request_h, cbId unsafe.Pointer) { | ||
id := uint64(uintptr((cbId))) | ||
if callback, found := getCallback(id); found { | ||
listener := connHandles2Listener[id] | ||
callback.(UcpListenerConnectionHandler)(&UcpConnectionRequest{ | ||
connRequest: connRequest, | ||
listener: listener, | ||
}) | ||
} | ||
} | ||
|
||
// Destination address | ||
func (p *UcpListenerParams) SetSocketAddress(a *net.TCPAddr) (*UcpListenerParams, error) { | ||
sockAddr, error := toSockAddr(a) | ||
if error != nil { | ||
return nil, error | ||
} | ||
|
||
p.params.field_mask |= C.UCP_LISTENER_PARAM_FIELD_SOCK_ADDR | ||
p.params.sockaddr = *sockAddr | ||
runtime.SetFinalizer(p, func(f *UcpListenerParams) { FreeNativeMemory(unsafe.Pointer(f.params.sockaddr.addr)) }) | ||
return p, nil | ||
} | ||
|
||
// Handler of an incoming connection request in a client-server connection flow. | ||
func (p *UcpListenerParams) SetConnectionHandler(connHandler UcpListenerConnectionHandler) *UcpListenerParams { | ||
var ucpConnHndl C.ucp_listener_conn_handler_t | ||
cbId := register(connHandler) | ||
|
||
p.connHandlerId = cbId | ||
ucpConnHndl.arg = unsafe.Pointer(uintptr(cbId)) | ||
ucpConnHndl.cb = (C.ucp_listener_conn_callback_t)(C.ucxgo_completeConnHandler) | ||
p.params.field_mask |= C.UCP_LISTENER_PARAM_FIELD_CONN_HANDLER | ||
p.params.conn_handler = ucpConnHndl | ||
return p | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.