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
tianlh
LightGBM-DCU
Commits
159e9a1e
"docker/git@developer.sourcefind.cn:tianlh/lightgbm-dcu.git" did not exist on "94fbe5bb9fbb5f6067821f0be9cd145f0b7d7d94"
Commit
159e9a1e
authored
Dec 14, 2017
by
Guolin Ke
Browse files
clean code for network functions
parent
0a7a4080
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
20 deletions
+19
-20
include/LightGBM/c_api.h
include/LightGBM/c_api.h
+5
-5
include/LightGBM/network.h
include/LightGBM/network.h
+3
-3
src/c_api.cpp
src/c_api.cpp
+11
-12
No files found.
include/LightGBM/c_api.h
View file @
159e9a1e
...
@@ -757,7 +757,7 @@ LIGHTGBM_C_EXPORT int LGBM_NetworkInit(const char* machines,
...
@@ -757,7 +757,7 @@ LIGHTGBM_C_EXPORT int LGBM_NetworkInit(const char* machines,
*/
*/
LIGHTGBM_C_EXPORT
int
LGBM_NetworkFree
();
LIGHTGBM_C_EXPORT
int
LGBM_NetworkFree
();
LIGHTGBM_C_EXPORT
int
LGBM_
G
etFuncions
(
void
*
AllreduceFuncPtr
,
LIGHTGBM_C_EXPORT
int
LGBM_
N
et
workInitWith
Func
t
ions
(
void
*
AllreduceFuncPtr
,
void
*
ReduceScatterFuncPtr
,
void
*
ReduceScatterFuncPtr
,
void
*
AllgatherFuncPtr
,
void
*
AllgatherFuncPtr
,
int
num_machines
,
int
num_machines
,
...
...
include/LightGBM/network.h
View file @
159e9a1e
...
@@ -191,9 +191,9 @@ public:
...
@@ -191,9 +191,9 @@ public:
/*! \brief set variables and function ptrs */
/*! \brief set variables and function ptrs */
static
void
SetRank
(
int
rank
)
{
rank_
=
rank
;}
static
void
SetRank
(
int
rank
)
{
rank_
=
rank
;}
static
void
SetNumMachines
(
int
num_machines
)
{
num_machines_
=
num_machines
;
}
static
void
SetNumMachines
(
int
num_machines
)
{
num_machines_
=
num_machines
;
}
static
void
SetAllReduce
(
AllreduceFunction
AllreduceFuncPtr
)
{
AllreduceFuncPtr_
=
AllreduceFuncPtr
;}
static
void
SetAllReduce
Function
(
AllreduceFunction
AllreduceFuncPtr
)
{
AllreduceFuncPtr_
=
AllreduceFuncPtr
;}
static
void
SetReduceScatter
(
ReduceScatterFunction
ReduceScatterFuncPtr
)
{
ReduceScatterFuncPtr_
=
ReduceScatterFuncPtr
;
}
static
void
SetReduceScatter
Function
(
ReduceScatterFunction
ReduceScatterFuncPtr
)
{
ReduceScatterFuncPtr_
=
ReduceScatterFuncPtr
;
}
static
void
SetAllgather
(
AllgatherFunction
AllgatherFuncPtr
)
{
AllgatherFuncPtr_
=
AllgatherFuncPtr
;
}
static
void
SetAllgather
Function
(
AllgatherFunction
AllgatherFuncPtr
)
{
AllgatherFuncPtr_
=
AllgatherFuncPtr
;
}
private:
private:
/*! \brief Number of all machines */
/*! \brief Number of all machines */
...
...
src/c_api.cpp
View file @
159e9a1e
...
@@ -1220,31 +1220,30 @@ int LGBM_NetworkFree() {
...
@@ -1220,31 +1220,30 @@ int LGBM_NetworkFree() {
API_END
();
API_END
();
}
}
int
LGBM_
G
etFuncions
(
void
*
AllreduceFuncPtr
,
int
LGBM_
N
et
workInitWith
Func
t
ions
(
void
*
AllreduceFuncPtr
,
void
*
ReduceScatterFuncPtr
,
void
*
ReduceScatterFuncPtr
,
void
*
AllgatherFuncPtr
,
void
*
AllgatherFuncPtr
,
int
num_machines
,
int
num_machines
,
int
rank
)
{
int
rank
)
{
API_BEGIN
();
API_BEGIN
();
if
(
num_machines
>
1
)
{
if
(
num_machines
>
1
)
{
auto
fun
c1
=
[
AllreduceFuncPtr
](
char
*
arg1
,
int
arg2
,
int
arg3
,
char
*
arg4
,
const
ReduceFunction
&
func
)
{
auto
allreduce_
fun
=
[
AllreduceFuncPtr
](
char
*
arg1
,
int
arg2
,
int
arg3
,
char
*
arg4
,
const
ReduceFunction
&
func
)
{
auto
ptr
=
*
func
.
target
<
ReduceFunctionInC
>
();
auto
ptr
=
*
func
.
target
<
ReduceFunctionInC
>
();
auto
tmp
=
(
void
(
*
)(
char
*
,
int
,
int
,
char
*
,
const
ReduceFunctionInC
&
))
AllreduceFuncPtr
;
auto
tmp
=
(
void
(
*
)(
char
*
,
int
,
int
,
char
*
,
const
ReduceFunctionInC
&
))
AllreduceFuncPtr
;
return
tmp
(
arg1
,
arg2
,
arg3
,
arg4
,
ptr
);
return
tmp
(
arg1
,
arg2
,
arg3
,
arg4
,
ptr
);
};
};
Network
::
SetAllReduce
(
fun
c1
);
Network
::
SetAllReduce
Function
(
allreduce_
fun
);
auto
fun
c2
=
[
ReduceScatterFuncPtr
](
char
*
arg1
,
int
arg2
,
const
int
*
arg3
,
const
int
*
arg4
,
char
*
arg5
,
const
ReduceFunction
&
func
)
{
auto
reduce_scatter_
fun
=
[
ReduceScatterFuncPtr
](
char
*
arg1
,
int
arg2
,
const
int
*
arg3
,
const
int
*
arg4
,
char
*
arg5
,
const
ReduceFunction
&
func
)
{
auto
ptr
=
*
func
.
target
<
ReduceFunctionInC
>
();
auto
ptr
=
*
func
.
target
<
ReduceFunctionInC
>
();
auto
tmp
=
(
void
(
*
)(
char
*
,
int
,
const
int
*
,
const
int
*
,
char
*
,
const
ReduceFunctionInC
&
))
ReduceScatterFuncPtr
;
auto
tmp
=
(
void
(
*
)(
char
*
,
int
,
const
int
*
,
const
int
*
,
char
*
,
const
ReduceFunctionInC
&
))
ReduceScatterFuncPtr
;
return
tmp
(
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
ptr
);
return
tmp
(
arg1
,
arg2
,
arg3
,
arg4
,
arg5
,
ptr
);
};
};
Network
::
SetReduceScatter
(
fun
c2
);
Network
::
SetReduceScatter
Function
(
reduce_scatter_
fun
);
Network
::
SetAllgather
((
void
(
*
)(
char
*
,
int
,
char
*
))
AllgatherFuncPtr
);
Network
::
SetAllgather
Function
((
void
(
*
)(
char
*
,
int
,
char
*
))
AllgatherFuncPtr
);
Network
::
SetNumMachines
(
num_machines
);
Network
::
SetNumMachines
(
num_machines
);
Network
::
SetRank
(
rank
);
Network
::
SetRank
(
rank
);
}
}
API_END
();
API_END
();
}
}
// ---- start of some help functions
// ---- start of some help functions
...
...
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