File indexing completed on 2025-01-18 10:00:10
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "gloo/context.h"
0012 #include "gloo/transport/unbound_buffer.h"
0013
0014 namespace gloo {
0015
0016 class AllgathervOptions {
0017 public:
0018 explicit AllgathervOptions(const std::shared_ptr<Context>& context)
0019 : context(context), timeout(context->getTimeout()) {}
0020
0021 template <typename T>
0022 void setInput(std::unique_ptr<transport::UnboundBuffer> buf) {
0023 setInput(std::move(buf), sizeof(T));
0024 }
0025
0026 template <typename T>
0027 void setInput(T* ptr, size_t elements) {
0028 setInput(static_cast<void*>(ptr), elements, sizeof(T));
0029 }
0030
0031 template <typename T>
0032 void setOutput(
0033 std::unique_ptr<transport::UnboundBuffer> buf,
0034 std::vector<size_t> elements) {
0035 setOutput(std::move(buf), std::move(elements), sizeof(T));
0036 }
0037
0038 template <typename T>
0039 void setOutput(T* ptr, std::vector<size_t> elements) {
0040 setOutput(static_cast<void*>(ptr), std::move(elements), sizeof(T));
0041 }
0042
0043 void setTag(uint32_t tag) {
0044 this->tag = tag;
0045 }
0046
0047 void setTimeout(std::chrono::milliseconds timeout) {
0048 this->timeout = timeout;
0049 }
0050
0051 protected:
0052 std::shared_ptr<Context> context;
0053 std::unique_ptr<transport::UnboundBuffer> in;
0054 std::unique_ptr<transport::UnboundBuffer> out;
0055
0056
0057 std::vector<size_t> elements;
0058
0059
0060 size_t elementSize = 0;
0061
0062
0063
0064 uint32_t tag = 0;
0065
0066
0067 std::chrono::milliseconds timeout;
0068
0069
0070 void setElementSize(size_t elementSize);
0071
0072
0073 void setInput(
0074 std::unique_ptr<transport::UnboundBuffer> buf,
0075 size_t elementSize);
0076
0077
0078 void setInput(void* ptr, size_t elements, size_t elementSize);
0079
0080
0081 void setOutput(
0082 std::unique_ptr<transport::UnboundBuffer> buf,
0083 std::vector<size_t> elements,
0084 size_t elementSize);
0085
0086
0087 void setOutput(void* ptr, std::vector<size_t> elements, size_t elementSize);
0088
0089 friend void allgatherv(AllgathervOptions&);
0090 };
0091
0092 void allgatherv(AllgathervOptions& opts);
0093
0094 }