use of org.openucx.jucx.ucp.UcpEndpointParams in project twister2 by DSC-SPIDAL.
the class TWSUCXChannel method createUXCWorker.
private void createUXCWorker(IWorkerController iWorkerController) {
UcpContext ucpContext = null;
UcpListener ucpListener = null;
// if UCX socket is already created, use that
// this happens in mpi clusters
Stack<Closeable> ucxObjects = (Stack<Closeable>) WorkerEnvironment.getSharedValue("ucxSocketsForFreePorts");
if (ucxObjects != null && ucxObjects.size() > 2) {
// todo: handle the case when there are multiple ucp sockets
while (!ucxObjects.isEmpty()) {
Closeable ucxObj = ucxObjects.pop();
if (ucxObj instanceof UcpListener) {
ucpListener = (UcpListener) ucxObj;
} else if (ucxObj instanceof UcpContext) {
ucpContext = (UcpContext) ucxObj;
} else if (ucxObj instanceof UcpWorker) {
ucpWorker = (UcpWorker) ucxObj;
} else {
LOG.warning("Unrecognized UCX object: " + ucxObj);
}
}
// add them to closeables
closeables.push(ucpContext);
closeables.push(ucpWorker);
closeables.push(ucpListener);
// create UCX objects
} else {
ucpContext = initUcpContext();
this.closeables.push(ucpContext);
this.ucpWorker = ucpContext.newWorker(new UcpWorkerParams().requestThreadSafety());
this.closeables.push(ucpWorker);
UcpListenerParams ucpListenerParams = new UcpListenerParams().setSockAddr(new InetSocketAddress(iWorkerController.getWorkerInfo().getWorkerIP(), iWorkerController.getWorkerInfo().getPort()));
// start listener
try {
ucpListener = ucpWorker.newListener(ucpListenerParams);
closeables.push(ucpListener);
} catch (org.openucx.jucx.UcxException ucxEx) {
throw new Twister2RuntimeException("Can not start TWSUCXChannel.", ucxEx);
}
}
try {
// wait till everyone add listeners
iWorkerController.waitOnBarrier();
} catch (TimeoutException e) {
LOG.log(Level.SEVERE, "Failed to wait on barrier", e);
}
// create end points
for (JobMasterAPI.WorkerInfo worker : iWorkerController.getJoinedWorkers()) {
if (worker.getWorkerID() != workerId) {
UcpEndpoint ucpEndpoint = ucpWorker.newEndpoint(new UcpEndpointParams().setSocketAddress(new InetSocketAddress(worker.getWorkerIP(), worker.getPort())));
this.endpoints.put(worker.getWorkerID(), ucpEndpoint);
this.closeables.push(ucpEndpoint);
}
}
}
Aggregations