Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9b67359d
提交
9b67359d
authored
5月 25, 2013
作者:
Vivek Kulkarni
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixing a few minor bugs. Using minimum no of threads/blocks as supported
上级
74447679
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
6 行删除
+23
-6
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+23
-6
没有找到文件。
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
9b67359d
...
@@ -1339,11 +1339,15 @@ __global__ void k_vector_add_fast(int numRowsX,
...
@@ -1339,11 +1339,15 @@ __global__ void k_vector_add_fast(int numRowsX,
long
*
d_indices_arr
,
long
*
d_indices_arr
,
int
num
)
int
num
)
{
{
int
i
=
(
blockIdx
.
x
);
for
(
int
i
=
(
blockIdx
.
x
);
i
<
num
;
i
+=
gridDim
.
x
)
int
j
=
(
threadIdx
.
x
);
{
for
(
int
j
=
(
threadIdx
.
x
);
j
<
numColsX
;
j
+=
blockDim
.
x
)
{
int
x_row
=
d_indices_arr
[
i
];
int
x_row
=
d_indices_arr
[
i
];
int
y_row
=
i
;
int
y_row
=
i
;
atomicAdd
(
&
X
[(
x_row
*
stridesX0
)
+
(
j
*
stridesX1
)],
Y
[(
y_row
*
stridesY0
)
+
(
j
*
stridesY1
)]);
atomicAdd
(
&
X
[(
x_row
*
stridesX0
)
+
(
j
*
stridesX1
)],
Y
[(
y_row
*
stridesY0
)
+
(
j
*
stridesY1
)]);
}
}
return
;
return
;
}
}
...
@@ -1804,18 +1808,31 @@ void CudaNdarray_vector_add_fast(CudaNdarray* py_self, CudaNdarray* py_other, Py
...
@@ -1804,18 +1808,31 @@ void CudaNdarray_vector_add_fast(CudaNdarray* py_self, CudaNdarray* py_other, Py
const
int
*
shapeY
=
CudaNdarray_HOST_DIMS
(
py_other
);
const
int
*
shapeY
=
CudaNdarray_HOST_DIMS
(
py_other
);
const
int
*
strX
=
CudaNdarray_HOST_STRIDES
(
py_self
);
const
int
*
strX
=
CudaNdarray_HOST_STRIDES
(
py_self
);
const
int
*
strY
=
CudaNdarray_HOST_STRIDES
(
py_other
);
const
int
*
strY
=
CudaNdarray_HOST_STRIDES
(
py_other
);
unsigned
int
size
=
(
unsigned
int
)
PyArray_SIZE
(
indices_arr
);
unsigned
int
size
=
(
unsigned
int
)
PyArray_SIZE
(
indices_arr
);
unsigned
int
num_threads_per_block
=
shapeY
[
1
];
unsigned
int
numcolsX
=
shapeX
[
1
];
unsigned
int
num_blocks
=
size
;
unsigned
int
num_threads_per_block
=
std
::
min
(
numcolsX
,
(
unsigned
int
)
NUM_VECTOR_OP_THREADS_PER_BLOCK
);
unsigned
int
num_blocks
=
std
::
min
(
size
,(
unsigned
int
)
NUM_VECTOR_OP_BLOCKS
);
dim3
n_blocks
(
num_blocks
);
dim3
n_blocks
(
num_blocks
);
dim3
n_threads
(
num_threads_per_block
);
dim3
n_threads
(
num_threads_per_block
);
long
*
d_indices_arr
=
NULL
;
long
*
d_indices_arr
=
NULL
;
long
*
cpu_indices_arr
=
(
long
*
)
malloc
(
sizeof
(
long
)
*
PyArray_SIZE
(
indices_arr
));
assert
(
cpu_indices_arr
);
d_indices_arr
=
(
long
*
)
device_malloc
(
sizeof
(
long
)
*
PyArray_SIZE
(
indices_arr
));
d_indices_arr
=
(
long
*
)
device_malloc
(
sizeof
(
long
)
*
PyArray_SIZE
(
indices_arr
));
assert
(
d_indices_arr
);
assert
(
d_indices_arr
);
for
(
int
j
=
0
;
j
<
size
;
j
++
)
{
long
*
el
=
(
long
*
)
PyArray_GETPTR1
(
indices_arr
,
j
);
cpu_indices_arr
[
j
]
=
*
el
;
}
cudaError_t
err
=
cudaMemcpy
(
d_indices_arr
,
cudaError_t
err
=
cudaMemcpy
(
d_indices_arr
,
PyArray_DATA
(
indices_arr
)
,
cpu_indices_arr
,
sizeof
(
long
)
*
PyArray_SIZE
(
indices_arr
)
,
sizeof
(
long
)
*
size
,
cudaMemcpyHostToDevice
);
cudaMemcpyHostToDevice
);
k_vector_add_fast
<<<
n_blocks
,
n_threads
>>>
(
shapeX
[
0
],
k_vector_add_fast
<<<
n_blocks
,
n_threads
>>>
(
shapeX
[
0
],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论