Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
lishen01
Sccl
Commits
571a75b5
Commit
571a75b5
authored
Aug 09, 2025
by
lishen
Browse files
完成全部网络的node建立,以及GPU到GPU的path物理路径搜索
parent
379c4128
Changes
44
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
896 deletions
+103
-896
src/include/debug.h
src/include/debug.h
+6
-6
src/utils/container.h
src/utils/container.h
+95
-0
src/utils/utils.cpp
src/utils/utils.cpp
+1
-372
src/utils/utils.h
src/utils/utils.h
+1
-518
No files found.
src/include/debug.h
View file @
571a75b5
...
...
@@ -48,8 +48,8 @@ static __thread int tid = -1; // 线程局
static
int
pid
=
-
1
;
// 存储当前进程的ID,默认值为-1
static
FILE
*
scclDebugFile
=
stdout
;
// 指向调试输出流的文件指针,默认指向标准输出(stdout
static
uint64_t
scclDebugMask
=
SCCL_LOG_
TOPO
|
SCCL_LOG_BOOTSTRAP
;
// Default debug sub-system mask is INIT and ENV
static
int
scclDebugLevel
=
-
1
;
// 初始化为 -1,表示未设置
static
uint64_t
scclDebugMask
=
SCCL_LOG_
GRAPH
/*
| SCCL_LOG_BOOTSTRAP
*/
;
// Default debug sub-system mask is INIT and ENV
static
int
scclDebugLevel
=
-
1
;
// 初始化为 -1,表示未设置
// 在文件顶部或适当位置定义变量
static
int
scclDebugPos
=
-
1
;
// 初始化为 -1,表示未设置
...
...
@@ -135,10 +135,10 @@ static void scclDebugInit() {
mask
=
SCCL_LOG_TOPO
;
}
else
if
(
strcasecmp
(
subsys
,
"BOOTSTRAP"
)
==
0
)
{
mask
=
SCCL_LOG_BOOTSTRAP
;
}
else
if
(
strcasecmp
(
subsys
,
"TRANSPORT"
)
==
0
)
{
mask
=
SCCL_LOG_TRANSPORT
;
}
else
if
(
strcasecmp
(
subsys
,
"GRAPH"
)
==
0
)
{
mask
=
SCCL_LOG_GRAPH
;
}
else
if
(
strcasecmp
(
subsys
,
"TRANSPORT"
)
==
0
)
{
mask
=
SCCL_LOG_TRANSPORT
;
}
else
if
(
strcasecmp
(
subsys
,
"CONNECT"
)
==
0
)
{
mask
=
SCCL_LOG_CONNECT
;
}
else
if
(
strcasecmp
(
subsys
,
"P2P"
)
==
0
)
{
...
...
@@ -245,9 +245,9 @@ void scclDebugLog(scclDebugLogSubSys_t pos_flags, const char* filepath, const ch
char
buffer
[
1024
];
size_t
len
=
0
;
if
constexpr
(
level
==
SCCL_LOG_WARN
)
{
len
=
snprintf
(
buffer
,
sizeof
(
buffer
),
"
\n
%s:%d:%d %s:%
s:%d
SCCL WARN "
,
hostname
,
pid
,
tid
,
filepath
,
filefunc
,
line
);
len
=
snprintf
(
buffer
,
sizeof
(
buffer
),
"
\n
%s:%d:%d %s:%
d - %s
SCCL WARN "
,
hostname
,
pid
,
tid
,
filepath
,
line
,
filefunc
);
}
else
if
constexpr
(
level
==
SCCL_LOG_INFO
)
{
len
=
snprintf
(
buffer
,
sizeof
(
buffer
),
"%s:%d:%d %s:%
s:%d
SCCL INFO "
,
hostname
,
pid
,
tid
,
filepath
,
filefunc
,
line
);
len
=
snprintf
(
buffer
,
sizeof
(
buffer
),
"%s:%d:%d %s:%
d - %s
SCCL INFO "
,
hostname
,
pid
,
tid
,
filepath
,
line
,
filefunc
);
}
if
(
len
)
{
...
...
src/utils/container.h
0 → 100644
View file @
571a75b5
#pragma once
#include <stdint.h>
namespace
sccl
{
// 实现类似于std::span的功能,将字节数组转换为类型数组
// 采用Vector的各种接口,区别在于ByteSpanVector对data元素为直接操作,而std::vector为拷贝
template
<
typename
T
>
class
ByteSpanVector
{
public:
// 构造函数,接受一个指向数据的指针和数据的容量
ByteSpanVector
(
void
*
data
,
size_t
capacity
)
:
data_
(
reinterpret_cast
<
T
*>
(
data
)),
capacity_
(
capacity
/
sizeof
(
T
)),
size_
(
0
)
{}
// 提供一个data()函数,返回指向数据的指针
T
*
data
()
const
{
return
data_
;
}
// 提供一个size()函数,返回当前已经写入的数据的数量
size_t
size
()
const
{
return
size_
;
}
// 提供一个capacity()函数,返回预留给数据的最大空间
size_t
capacity
()
const
{
return
capacity_
;
}
// 提供一个空的检查函数
bool
empty
()
const
{
return
size_
==
0
;
}
// 提供一个检查是否已满的函数
bool
full
()
const
{
return
size_
==
capacity_
;
}
// 提供一个在末尾添加元素的函数
void
push_back
(
const
T
&
value
)
{
if
(
size_
<
capacity_
)
{
new
(
data_
+
size_
)
T
(
value
);
++
size_
;
}
else
{
// 处理容量不足的情况,例如抛出异常或扩展容量
throw
std
::
overflow_error
(
"ByteSpanVector push_back capacity exceeded"
);
}
}
// 提供一个访问指定索引处元素的函数,返回指针
T
*
operator
[](
size_t
index
)
{
if
(
index
<
size_
)
{
return
&
(
data_
[
index
]);
}
else
{
return
nullptr
;
// 返回空指针
}
}
const
T
*
operator
[](
size_t
index
)
const
{
if
(
index
<
size_
)
{
return
&
(
data_
[
index
]);
}
else
{
return
nullptr
;
// 返回空指针
}
}
private:
T
*
data_
;
size_t
capacity_
;
size_t
size_
;
};
template
<
typename
T
>
class
ByteSpanArray
{
public:
// 构造函数,接受一个指向数据的void*指针和总的字节大小
ByteSpanArray
(
void
*
data
,
size_t
size
)
:
data_
(
reinterpret_cast
<
T
*>
(
data
)),
size_
(
size
/
sizeof
(
T
))
{}
// 提供一个size()函数,返回当前已经写入的数据的数量
size_t
size
()
const
{
return
size_
;
}
// 提供一个访问指定索引处元素的函数,返回T*类型的数据,或者在索引超出范围时返回空指针nullptr
T
*
operator
[](
size_t
index
)
{
if
(
index
<
size_
)
{
return
data_
+
index
;
}
else
{
return
nullptr
;
}
}
const
T
*
operator
[](
size_t
index
)
const
{
if
(
index
<
size_
)
{
return
data_
+
index
;
}
else
{
return
nullptr
;
}
}
private:
T
*
data_
;
size_t
size_
;
};
}
// namespace sccl
src/utils/utils.cpp
View file @
571a75b5
This diff is collapsed.
Click to expand it.
src/utils/utils.h
View file @
571a75b5
This diff is collapsed.
Click to expand it.
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment