mirror of
https://github.com/microsoft/mscclpp.git
synced 2026-05-12 09:17:06 +00:00
Reorganize current native algorithm implementation and DSL algorithm implementation. Provide unified API for DSL algo and native algo and provide interface to tune the algo Provide interface for pytorch integration with native API and DSL --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: chhwang <8018170+chhwang@users.noreply.github.com>
25 lines
626 B
C++
25 lines
626 B
C++
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT license.
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <chrono>
|
|
#include <mscclpp/errors.hpp>
|
|
#include <mscclpp/utils.hpp>
|
|
#include <string>
|
|
|
|
namespace mscclpp {
|
|
|
|
std::string getHostName(int maxlen, const char delim) {
|
|
std::string hostname(maxlen + 1, '\0');
|
|
if (gethostname(const_cast<char*>(hostname.data()), maxlen) != 0) {
|
|
throw Error("gethostname failed", ErrorCode::SystemError);
|
|
}
|
|
int i = 0;
|
|
while ((hostname[i] != delim) && (hostname[i] != '\0') && (i < maxlen - 1)) i++;
|
|
hostname[i] = '\0';
|
|
return hostname.substr(0, i);
|
|
}
|
|
|
|
} // namespace mscclpp
|