Realm
A distributed, event-based tasking library
Loading...
Searching...
No Matches
worker.h
Go to the documentation of this file.
1/*
2 * Copyright 2025 NVIDIA Corporation
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef __WORKER_H__
19#define __WORKER_H__
20
21#include <cmath>
22#include <unordered_map>
23#include <queue>
24
25#include "client.h"
26#include "logger.h"
27#include "server.h"
28#include "types.h"
29
30namespace mesh {
31 // @class Worker
32 // @brief Representation of rank/dask worker.
33
34 // Worker class responsible for creating mesh topology and all the p2p send
35 // and receive of the information.
36 class Worker {
37 std::unique_ptr<mesh::Server> server_{nullptr};
38 std::unique_ptr<mesh::Client> client_{nullptr};
39
40 // Peers ip and port identity
41 mesh::NodeIdent self_;
42 std::unordered_map<std::string, mesh::NodeIdent> peers_;
43
44 std::shared_ptr<p2p::Logger::p2p_log> p2p_log_{nullptr};
45
46 public:
47 Worker(const std::string &self, const std::vector<std::string> &peers);
48
49 // @brief Establish the mesh-topology among all the member processes.
50 int init();
51
52 // @brief Shutdown the mesh topology
53 int shutdown();
54
55 int send_buf(const std::string &dst, void *buf, size_t len);
56
57 int recv_buf(const std::string &src, void *buf, size_t len);
58 };
59} // namespace mesh
60
61#endif
Definition worker.h:36
int recv_buf(const std::string &src, void *buf, size_t len)
Worker(const std::string &self, const std::vector< std::string > &peers)
int send_buf(const std::string &dst, void *buf, size_t len)
Definition client.h:29
Definition types.h:27
NodeID src
Definition ucp_internal.h:1