Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
9eeabe98
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9eeabe98
编写于
7月 04, 2017
作者:
Q
qijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
follow comments
上级
76b7be46
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
119 addition
and
47 deletion
+119
-47
paddle/platform/cublas.h
paddle/platform/cublas.h
+39
-19
paddle/platform/cudnn.h
paddle/platform/cudnn.h
+29
-9
paddle/platform/curand.h
paddle/platform/curand.h
+30
-10
paddle/platform/dynamic_loader.cc
paddle/platform/dynamic_loader.cc
+14
-2
paddle/platform/dynamic_loader.h
paddle/platform/dynamic_loader.h
+7
-7
未找到文件。
paddle/platform/cublas.h
浏览文件 @
9eeabe98
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <cublas_v2.h>
#include "paddle/platform/dynamic_loader.h"
namespace
paddle
{
namespace
platform
{
namespace
dyload
{
std
::
once_flag
cublas_dso_flag
;
...
...
@@ -20,7 +37,9 @@ void *cublas_dso_handle = nullptr;
template <typename... Args> \
cublasStatus_t operator()(Args... args) { \
typedef cublasStatus_t (*cublasFunc)(Args...); \
std::call_once(cublas_dso_flag, GetCublasDsoHandle, &cublas_dso_handle); \
std::call_once(cublas_dso_flag, \
paddle::platform::dyload::GetCublasDsoHandle, \
&cublas_dso_handle); \
void *p_##__name = dlsym(cublas_dso_handle, #__name); \
return reinterpret_cast<cublasFunc>(p_##__name)(args...); \
} \
...
...
@@ -68,17 +87,18 @@ CUBLAS_BLAS_ROUTINE_EACH(DYNAMIC_LOAD_CUBLAS_V2_WRAP)
// clang-format on
#ifndef PADDLE_TYPE_DOUBLE
#define CUBLAS_GEAM dynload::cublasSgeam
#define CUBLAS_GEMV dynload::cublasSgemv
#define CUBLAS_GEMM dynload::cublasSgemm
#define CUBLAS_GETRF dynload::cublasSgetrfBatched
#define CUBLAS_GETRI dynload::cublasSgetriBatched
#define CUBLAS_GEAM
paddle::platform::
dynload::cublasSgeam
#define CUBLAS_GEMV
paddle::platform::
dynload::cublasSgemv
#define CUBLAS_GEMM
paddle::platform::
dynload::cublasSgemm
#define CUBLAS_GETRF
paddle::platform::
dynload::cublasSgetrfBatched
#define CUBLAS_GETRI
paddle::platform::
dynload::cublasSgetriBatched
#else
#define CUBLAS_GEAM dynload::cublasDgeam
#define CUBLAS_GEMV dynload::cublasDgemv
#define CUBLAS_GEMM dynload::cublasDgemm
#define CUBLAS_GETRF dynload::cublasDgetrfBatched
#define CUBLAS_GETRI dynload::cublasDgetriBatched
#define CUBLAS_GEAM
paddle::platform::
dynload::cublasDgeam
#define CUBLAS_GEMV
paddle::platform::
dynload::cublasDgemv
#define CUBLAS_GEMM
paddle::platform::
dynload::cublasDgemm
#define CUBLAS_GETRF
paddle::platform::
dynload::cublasDgetrfBatched
#define CUBLAS_GETRI
paddle::platform::
dynload::cublasDgetriBatched
#endif
}
// namespace dyload
}
// namespace platform
}
// namespace paddle
paddle/platform/cudnn.h
浏览文件 @
9eeabe98
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <cudnn.h>
#include "paddle/platform/dynamic_loader.h"
namespace
paddle
{
namespace
platform
{
namespace
dyload
{
std
::
once_flag
cudnn_dso_flag
;
...
...
@@ -14,7 +31,9 @@ void* cudnn_dso_handle = nullptr;
template <typename... Args> \
auto operator()(Args... args) -> decltype(__name(args...)) { \
using cudnn_func = decltype(__name(args...)) (*)(Args...); \
std::call_once(cudnn_dso_flag, GetCudnnDsoHandle, &cudnn_dso_handle); \
std::call_once(cudnn_dso_flag, \
paddle::platform::dyload::GetCudnnDsoHandle, \
&cudnn_dso_handle); \
void* p_##__name = dlsym(cudnn_dso_handle, #__name); \
return reinterpret_cast<cudnn_func>(p_##__name)(args...); \
} \
...
...
@@ -111,4 +130,5 @@ CUDNN_DNN_ROUTINE_EACH_R5(DYNAMIC_LOAD_CUDNN_WRAP)
#undef CUDNN_DNN_ROUTINE_EACH
// clang-format on
}
// namespace dyload
}
// namespace platform
}
// namespace paddle
paddle/platform/curand.h
浏览文件 @
9eeabe98
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserve.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include <curand.h>
#include "paddle/platform/dynamic_loader.h"
namespace
paddle
{
namespace
platform
{
namespace
dyload
{
std
::
once_flag
curand_dso_flag
;
void
*
curand_dso_handle
=
nullptr
;
...
...
@@ -11,7 +28,9 @@ void *curand_dso_handle = nullptr;
template <typename... Args> \
curandStatus_t operator()(Args... args) { \
typedef curandStatus_t (*curandFunc)(Args...); \
std::call_once(curand_dso_flag, GetCurandDsoHandle, &curand_dso_handle); \
std::call_once(curand_dso_flag, \
paddle::platform::dyload::GetCurandDsoHandle, \
&curand_dso_handle); \
void *p_##__name = dlsym(curand_dso_handle, #__name); \
return reinterpret_cast<curandFunc>(p_##__name)(args...); \
} \
...
...
@@ -41,5 +60,6 @@ CURAND_RAND_ROUTINE_EACH(DYNAMIC_LOAD_CURAND_WRAP)
#undef CURAND_RAND_ROUTINE_EACH
#undef DYNAMIC_LOAD_CURAND_WRAP
}
}
// namespace dyload
}
// namespace platform
}
// namespace paddle
paddle/platform/dynamic_loader.cc
浏览文件 @
9eeabe98
...
...
@@ -13,8 +13,12 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "dynamic_loader.h"
#include <gflags/gflags.h>
#include <glog/logging.h>
#include <dlfcn.h>
#include <memory>
#include <mutex>
#include <string>
#include "gflags/gflags.h"
#include "glog/logging.h"
DEFINE_string
(
cudnn_dir
,
""
,
"Specify path for loading libcudnn.so. For instance, "
...
...
@@ -30,6 +34,10 @@ DEFINE_string(warpctc_dir, "", "Specify path for loading libwarpctc.so.");
DEFINE_string
(
lapack_dir
,
""
,
"Specify path for loading liblapack.so."
);
namespace
paddle
{
namespace
platform
{
namespace
dyload
{
static
inline
std
::
string
join
(
const
std
::
string
&
part1
,
const
std
::
string
&
part2
)
{
// directory separator
...
...
@@ -155,3 +163,7 @@ void GetLapackDsoHandle(void** dso_handle) {
GetDsoHandleFromSearchPath
(
FLAGS_lapack_dir
,
"liblapacke.so"
,
dso_handle
);
#endif
}
}
// namespace dyload
}
// namespace platform
}
// namespace paddle
paddle/platform/dynamic_loader.h
浏览文件 @
9eeabe98
...
...
@@ -12,13 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#ifndef DYNAMIC_LOAD_H_
#define DYNAMIC_LOAD_H_
#pragma once
#include <dlfcn.h>
#include <memory>
#include <mutex>
#include <string>
namespace
paddle
{
namespace
platform
{
namespace
dyload
{
/**
* @brief load the DSO of CUBLAS
...
...
@@ -60,4 +58,6 @@ void GetWarpCTCDsoHandle(void** dso_handle);
*/
void
GetLapackDsoHandle
(
void
**
dso_handle
);
#endif // DYNAMIC_LOAD_H_
}
// namespace dyload
}
// namespace platform
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录