Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
NiuTrans.Tensor
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
8
Issues
8
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
NiuTrans
NiuTrans.Tensor
Commits
feb29d20
Commit
feb29d20
authored
Feb 23, 2021
by
xiaotong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates of SetDevice
parent
2b03a447
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
37 行增加
和
10 行删除
+37
-10
source/tensor/XDevice.cpp
+22
-0
source/tensor/XDevice.h
+10
-2
source/tensor/XQueue.cpp
+4
-7
source/tensor/XQueue.h
+1
-1
没有找到文件。
source/tensor/XDevice.cpp
查看文件 @
feb29d20
...
...
@@ -268,6 +268,28 @@ int XDevice::GetGPUDevice()
#endif
}
/*
swith to a device (CPU or GPU)
>> devID - device id
*/
void
XDevice
::
SetDevice
(
int
devID
)
{
if
(
devID
>=
0
)
SetGPUDevice
(
devID
);
}
/*
swith to a device (CPU or GPU) with a backup of the device id
>> devID - device id
>> backupDevID - backup of the device id
*/
void
XDevice
::
SetDevice
(
int
devID
,
int
&
backupDevID
)
{
backupDevID
=
GetGPUDevice
();
if
(
devID
>=
0
)
SetGPUDevice
(
devID
);
}
/* reset cuda flag for more efficient cuda execution. It should be called after "SetGPUDevice" when
no GPU context has been established. */
void
XDevice
::
SetFastFlags
()
...
...
source/tensor/XDevice.h
查看文件 @
feb29d20
...
...
@@ -138,7 +138,7 @@ public:
cublasHandle_t
*
GetCublasHandle
();
#endif
/* switch to a device */
/* switch to a
GPU
device */
static
void
SetGPUDevice
(
int
devID
);
...
...
@@ -146,10 +146,18 @@ public:
static
void
SetGPUDeviceFast
(
int
devID
);
/*
switch to a
get current dev */
/* get current dev */
static
int
GetGPUDevice
();
/* swith to a device (CPU or GPU) */
static
void
SetDevice
(
int
devID
);
/* swith to a device (CPU or GPU) with a backup of the device id */
static
void
SetDevice
(
int
devID
,
int
&
backupDevID
);
/* reset cuda flag for more efficient cuda execution */
static
void
SetFastFlags
();
...
...
source/tensor/XQueue.cpp
查看文件 @
feb29d20
...
...
@@ -170,7 +170,7 @@ void XQueue::RunJobConsumer(int jobDevID)
isJobQueue
=
true
;
jobDequeuerArgs
->
Clear
();
/
/ warning: this may cause unknown error
/
* warning: this may cause unknown errors */
jobDequeuerArgs
->
Add
(
this
);
jobDequeuerArgs
->
Add
(
jobDevID
>=
0
?
(
devids
+
jobDevID
)
:
&
cpuid
);
...
...
@@ -214,10 +214,8 @@ void XQueue::DequeueJobs(XList * args)
XQueue
*
q
=
(
XQueue
*
)
args
->
GetItem
(
0
);
int
devID
=
*
(
int
*
)
args
->
GetItem
(
1
);
int
devIDBackup
=
XDevice
::
GetGPUDevice
();
if
(
devID
>=
0
)
XDevice
::
SetGPUDevice
(
devID
);
int
devIDBackup
=
-
1
;
XDevice
::
SetDevice
(
devID
,
devIDBackup
);
while
(
1
){
JobQueueNode
*
node
=
(
JobQueueNode
*
)
q
->
Dequeue
();
...
...
@@ -238,8 +236,7 @@ void XQueue::DequeueJobs(XList * args)
}
if
(
devID
>=
0
)
XDevice
::
SetGPUDevice
(
devIDBackup
);
XDevice
::
SetDevice
(
devIDBackup
);
}
/* get the break flag */
...
...
source/tensor/XQueue.h
查看文件 @
feb29d20
...
...
@@ -129,7 +129,7 @@ public:
void
WaitForEmptyJobQueue
();
/* run the job consumer */
void
RunJobConsumer
(
int
jobDevID
=
0
);
void
RunJobConsumer
(
int
jobDevID
=
-
1
);
/* stop the job consumer */
void
StopJobConsumer
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论