Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
445d1e82
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看板
提交
445d1e82
编写于
9月 09, 2016
作者:
L
liaogang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support MAC OS for PaddlePaddle
上级
33767364
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
361 addition
and
38 deletion
+361
-38
cmake/cudnn.cmake
cmake/cudnn.cmake
+1
-1
cmake/flags.cmake
cmake/flags.cmake
+2
-2
cmake/util.cmake
cmake/util.cmake
+32
-9
paddle/api/Util.cpp
paddle/api/Util.cpp
+1
-0
paddle/gserver/dataproviders/PyDataProvider.cpp
paddle/gserver/dataproviders/PyDataProvider.cpp
+2
-0
paddle/gserver/gradientmachines/NeuralNetwork.cpp
paddle/gserver/gradientmachines/NeuralNetwork.cpp
+6
-6
paddle/math/Allocator.h
paddle/math/Allocator.h
+9
-4
paddle/math/MathFunctions.h
paddle/math/MathFunctions.h
+2
-0
paddle/math/Storage.cpp
paddle/math/Storage.cpp
+2
-2
paddle/pserver/LightNetwork.cpp
paddle/pserver/LightNetwork.cpp
+23
-6
paddle/pserver/SocketChannel.cpp
paddle/pserver/SocketChannel.cpp
+10
-2
paddle/trainer/Trainer.cpp
paddle/trainer/Trainer.cpp
+1
-0
paddle/trainer/TrainerMain.cpp
paddle/trainer/TrainerMain.cpp
+1
-0
paddle/utils/Excepts.cpp
paddle/utils/Excepts.cpp
+54
-0
paddle/utils/Excepts.h
paddle/utils/Excepts.h
+26
-0
paddle/utils/Locks.cpp
paddle/utils/Locks.cpp
+106
-0
paddle/utils/Locks.h
paddle/utils/Locks.h
+69
-0
paddle/utils/PythonUtil.h
paddle/utils/PythonUtil.h
+14
-6
未找到文件。
cmake/cudnn.cmake
浏览文件 @
445d1e82
...
...
@@ -15,7 +15,7 @@ list(APPEND CUDNN_CHECK_LIBRARY_DIRS
$ENV{CUDNN_ROOT}/lib64
$ENV{CUDNN_ROOT}/lib
/usr/lib
)
find_library
(
CUDNN_LIBRARY NAMES libcudnn.so
# libcudnn_static.a
find_library
(
CUDNN_LIBRARY NAMES libcudnn.so
libcudnn.dylib
# libcudnn_static.a
PATHS
${
CUDNN_CHECK_LIBRARY_DIRS
}
${
CUDNN_INCLUDE_DIR
}
${
__libpath_hist
}
NO_DEFAULT_PATH
DOC
"Path to cuDNN library."
)
...
...
cmake/flags.cmake
浏览文件 @
445d1e82
...
...
@@ -58,8 +58,8 @@ set(COMMON_FLAGS
-fPIC
-fno-omit-frame-pointer
-Wall
-Wextra
-Werror
#
-Wextra
#
-Werror
-Wnon-virtual-dtor
-Wdelete-non-virtual-dtor
-Wno-unused-parameter
...
...
cmake/util.cmake
浏览文件 @
445d1e82
# Some common routine for paddle compile.
if
(
APPLE
)
# -------------------------------------------------------
# OSX
# -------------------------------------------------------
set
(
GROUP_START
"-Wl,-force_load"
)
set
(
GROUP_END
""
)
set
(
ARCHIVE_START
"-Wl,-force_load"
)
set
(
ARCHIVE_END
""
)
else
()
set
(
GROUP_START
"-Wl,--start-group"
)
set
(
GROUP_END
"-Wl,--end-group"
)
set
(
ARCHIVE_START
"-Wl,--whole-archive"
)
set
(
ARCHIVE_END
"-Wl,--no-whole-archive"
)
endif
()
# target_circle_link_libraries
...
...
@@ -7,10 +24,18 @@
# First Argument: target name want to be linked with libraries
# Rest Arguments: libraries which link together.
function
(
target_circle_link_libraries TARGET_NAME
)
target_link_libraries
(
${
TARGET_NAME
}
-Wl,--start-group
${
ARGN
}
-Wl,--end-group
)
if
(
APPLE
)
foreach
(
f
${
ARGN
}
)
list
(
APPEND OSX_LIBRARIES
"-Wl,-force_load"
"
${
f
}
"
)
endforeach
(
f
)
target_link_libraries
(
${
TARGET_NAME
}
${
OSX_LIBRARIES
}
)
else
()
target_link_libraries
(
${
TARGET_NAME
}
${
GROUP_START
}
${
ARGN
}
${
GROUP_END
}
)
endif
()
endfunction
()
# compile_cu_as_cpp
...
...
@@ -41,20 +66,18 @@ function(link_paddle_exe TARGET_NAME)
if
(
PADDLE_WITH_INTERNAL
)
set
(
INTERAL_LIBS paddle_internal_gserver paddle_internal_parameter
)
target_circle_link_libraries
(
${
TARGET_NAME
}
-Wl,--whole-archive
paddle_internal_gserver
paddle_internal_owlqn
-Wl,--no-whole-archive
paddle_internal_parameter
)
else
()
set
(
INTERAL_LIBS
""
)
endif
()
target_circle_link_libraries
(
${
TARGET_NAME
}
-Wl,--whole-archive
# ${ARCHIVE_START}
paddle_gserver
${
METRIC_LIBS
}
-Wl,--no-whole-archive
# ${ARCHIVE_END}
paddle_pserver
paddle_trainer_lib
paddle_network
...
...
@@ -69,7 +92,7 @@ function(link_paddle_exe TARGET_NAME)
${
CBLAS_LIBS
}
${
CMAKE_DL_LIBS
}
${
INTERAL_LIBS
}
-lz
)
)
if
(
WITH_PYTHON
)
target_link_libraries
(
${
TARGET_NAME
}
...
...
paddle/api/Util.cpp
浏览文件 @
445d1e82
...
...
@@ -17,6 +17,7 @@ limitations under the License. */
#include "paddle/utils/Util.h"
#include "paddle/utils/PythonUtil.h"
#include "paddle/utils/Flags.h"
#include "paddle/utils/Excepts.h"
#include "paddle/parameter/Parameter.h"
#include <fenv.h>
...
...
paddle/gserver/dataproviders/PyDataProvider.cpp
浏览文件 @
445d1e82
...
...
@@ -17,6 +17,8 @@ limitations under the License. */
#include "paddle/utils/PythonUtil.h"
#include <fenv.h>
#include "paddle/utils/Util.h"
#include "paddle/utils/Excepts.h"
namespace
paddle
{
...
...
paddle/gserver/gradientmachines/NeuralNetwork.cpp
浏览文件 @
445d1e82
...
...
@@ -384,17 +384,17 @@ void NeuralNetwork::setOutputGrad(const std::vector<Argument>& args) {
}
}
extern
NeuralNetwork
*
newCustomNeuralNetwork
(
const
std
::
string
&
name
,
NeuralNetwork
*
network
)
__attribute__
((
weak
));
//
extern NeuralNetwork* newCustomNeuralNetwork(
//
const std::string& name, NeuralNetwork* network) __attribute__((weak));
NeuralNetwork
*
NeuralNetwork
::
newNeuralNetwork
(
const
std
::
string
&
name
,
NeuralNetwork
*
rootNetwork
)
{
if
(
newCustomNeuralNetwork
)
{
return
newCustomNeuralNetwork
(
name
,
rootNetwork
);
}
else
{
//
if (newCustomNeuralNetwork) {
//
return newCustomNeuralNetwork(name, rootNetwork);
//
} else {
return
new
NeuralNetwork
(
name
,
rootNetwork
);
}
//
}
}
}
// namespace paddle
paddle/math/Allocator.h
浏览文件 @
445d1e82
...
...
@@ -16,7 +16,7 @@ limitations under the License. */
#pragma once
#include <mutex>
#include <
malloc
.h>
#include <
stdlib
.h>
#include "hl_gpu.h"
#include "paddle/utils/Logging.h"
...
...
@@ -48,9 +48,14 @@ public:
* @return Pointer to the allocated memory
*/
virtual
void
*
alloc
(
size_t
size
)
{
void
*
ptr
=
memalign
(
32ul
,
size
);
CHECK
(
ptr
)
<<
"Fail to allocate CPU memory: size="
<<
size
;
return
ptr
;
#if defined(__APPLE__) || defined(__OSX__)
return
malloc
(
size
);
#else
void
*
ptr
;
posix_memalign
(
&
ptr
,
32ul
,
size
);
CHECK
(
ptr
)
<<
"Fail to allocate CPU memory: size="
<<
size
;
return
ptr
;
#endif
}
/**
...
...
paddle/math/MathFunctions.h
浏览文件 @
445d1e82
...
...
@@ -23,6 +23,8 @@ extern "C" {
}
#endif
#include <cmath>
namespace
paddle
{
template
<
class
T
>
...
...
paddle/math/Storage.cpp
浏览文件 @
445d1e82
...
...
@@ -25,8 +25,8 @@ namespace paddle {
// Initialization StorageEngine singleton.
// Other modules may rely on storage management,
// so StorageEngine need to be initialized before other modules.
static
InitFunction
__init_storage_engine
(
StorageEngine
::
singleton
,
std
::
numeric_limits
<
int
>::
max
());
//
static InitFunction __init_storage_engine(
//
StorageEngine::singleton, std::numeric_limits<int>::max());
StorageEngine
::
StorageEngine
()
:
cpuAllocator_
(
nullptr
)
{
}
...
...
paddle/pserver/LightNetwork.cpp
浏览文件 @
445d1e82
...
...
@@ -24,7 +24,12 @@ limitations under the License. */
#include <net/if.h>
#include <net/if_arp.h>
#include <sstream>
#if defined(__OSX__) || defined(__APPLE__)
#include <netinet/tcp.h>
#else
#include <linux/tcp.h>
#endif
#include "LightNetwork.h"
#include "paddle/utils/Util.h"
...
...
@@ -92,10 +97,12 @@ void setOption(int sockfd) {
CHECK_GE
(
setsockopt
(
sockfd
,
IPPROTO_TCP
,
TCP_NODELAY
,
&
optval
,
sizeof
(
optval
)),
0
);
#ifdef TCP_QUICKACK
optval
=
1
;
CHECK_GE
(
setsockopt
(
sockfd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
&
optval
,
sizeof
(
optval
)),
0
);
#endif
}
int
reuse
=
1
;
CHECK_GE
(
setsockopt
(
sockfd
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
reuse
,
sizeof
(
reuse
)),
...
...
@@ -340,17 +347,27 @@ void SocketWorker::run() {
*/
void
SocketClient
::
TcpClient
(
const
std
::
string
&
serverAddr
,
int
serverPort
)
{
struct
sockaddr_in
serv_addr
;
struct
hostent
hostinfo
,
*
server
;
char
buf
[
1024
];
// temp for gethostbyname_r
struct
hostent
*
server
;
int
errRet
;
// temp for gethostbyname_r
/// Create a socket point
int
sockfd
=
socket
(
AF_INET
,
SOCK_STREAM
,
0
);
PCHECK
(
sockfd
>=
0
)
<<
"ERROR opening socket"
;
CHECK_EQ
(
0
,
gethostbyname_r
(
serverAddr
.
c_str
(),
&
hostinfo
,
buf
,
sizeof
(
buf
),
&
server
,
&
errRet
))
<<
"ERROR, no such host: "
<<
serverAddr
<<
" ret = "
<<
errRet
;
CHECK
(
server
)
<<
"gethostbyname_r err"
;
#if defined(__OSX__) || defined(__APPLE__)
server
=
getipnodebyname
(
serverAddr
.
c_str
(),
AF_INET
,
AI_DEFAULT
,
&
errRet
);
CHECK_NE
(
HOST_NOT_FOUND
,
errRet
)
<<
"ERROR, no such host: "
<<
serverAddr
<<
" ret = "
<<
errRet
;
CHECK
(
server
)
<<
"getipnodebyname error!"
;
#else
struct
hostent
hostinfo
;
char
buf
[
1024
];
// temp for gethostbyname_r
CHECK_EQ
(
0
,
gethostbyname_r
(
serverAddr
.
c_str
(),
&
hostinfo
,
buf
,
sizeof
(
buf
),
&
server
,
&
errRet
))
<<
"ERROR, no such host: "
<<
serverAddr
<<
" ret = "
<<
errRet
;
CHECK
(
server
)
<<
"gethostbyname_r error!"
;
#endif
bzero
((
char
*
)
&
serv_addr
,
sizeof
(
serv_addr
));
serv_addr
.
sin_family
=
AF_INET
;
...
...
paddle/pserver/SocketChannel.cpp
浏览文件 @
445d1e82
...
...
@@ -27,6 +27,15 @@ limitations under the License. */
namespace
paddle
{
/**
* UIO_MAXIOV is documented in writev(2), but <sys/uio.h> only
* declares it on osx/ios if defined(KERNEL)
*/
#ifndef UIO_MAXIOV
#define UIO_MAXIOV 512
#endif
SocketChannel
::~
SocketChannel
()
{
if
(
tcpRdma_
==
F_TCP
)
close
(
tcpSocket_
);
...
...
@@ -148,8 +157,7 @@ void SocketChannel::writeMessage(const std::vector<struct iovec>& userIovs) {
std
::
vector
<
iovec
>
iovs
;
iovs
.
reserve
(
userIovs
.
size
()
+
2
);
iovs
.
push_back
({
&
header
,
sizeof
(
header
)});
iovs
.
push_back
({
&
iovLengths
[
0
],
sizeof
(
iovLengths
[
0
])
*
(
size_t
)
header
.
numIovs
});
iovs
.
push_back
({
&
iovLengths
[
0
],
sizeof
(
iovLengths
[
0
])
*
header
.
numIovs
});
iovs
.
insert
(
iovs
.
end
(),
userIovs
.
begin
(),
userIovs
.
end
());
header
.
totalLength
=
0
;
...
...
paddle/trainer/Trainer.cpp
浏览文件 @
445d1e82
...
...
@@ -28,6 +28,7 @@ limitations under the License. */
#include "paddle/utils/PythonUtil.h"
#include "paddle/utils/Stat.h"
#include "paddle/utils/Util.h"
#include "paddle/utils/Excepts.h"
#include "paddle/utils/GlobalConstants.h"
#include "paddle/gserver/gradientmachines/NeuralNetwork.h"
...
...
paddle/trainer/TrainerMain.cpp
浏览文件 @
445d1e82
...
...
@@ -16,6 +16,7 @@ limitations under the License. */
#include <fenv.h>
#include "paddle/utils/PythonUtil.h"
#include "paddle/utils/StringUtil.h"
#include "paddle/utils/Excepts.h"
#include "paddle/pserver/ParameterServer2.h"
#include "ParamUtil.h"
...
...
paddle/utils/Excepts.cpp
0 → 100644
浏览文件 @
445d1e82
/* Copyright (c) 2016 Baidu, Inc. 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. */
#include "Excepts.h"
#if defined(__APPLE__) || defined(__OSX__)
#include <fenv.h>
int
fegetexcept
(
void
)
{
static
fenv_t
fenv
;
return
fegetenv
(
&
fenv
)
?
-
1
:
(
fenv
.
__control
&
FE_ALL_EXCEPT
);
}
int
feenableexcept
(
unsigned
int
excepts
)
{
static
fenv_t
fenv
;
unsigned
int
new_excepts
=
excepts
&
FE_ALL_EXCEPT
,
old_excepts
;
if
(
fegetenv
(
&
fenv
)
)
return
-
1
;
old_excepts
=
fenv
.
__control
&
FE_ALL_EXCEPT
;
// unmask
fenv
.
__control
&=
~
new_excepts
;
fenv
.
__mxcsr
&=
~
(
new_excepts
<<
7
);
return
(
fesetenv
(
&
fenv
)
?
-
1
:
old_excepts
);
}
int
fedisableexcept
(
unsigned
int
excepts
)
{
static
fenv_t
fenv
;
unsigned
int
new_excepts
=
excepts
&
FE_ALL_EXCEPT
,
old_excepts
;
if
(
fegetenv
(
&
fenv
)
)
return
-
1
;
old_excepts
=
fenv
.
__control
&
FE_ALL_EXCEPT
;
// mask
fenv
.
__control
|=
new_excepts
;
fenv
.
__mxcsr
|=
new_excepts
<<
7
;
return
(
fesetenv
(
&
fenv
)
?
-
1
:
old_excepts
);
}
#endif
paddle/utils/Excepts.h
0 → 100644
浏览文件 @
445d1e82
/* Copyright (c) 2016 Baidu, Inc. 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. */
#ifndef EXCEPTS_H_
#define EXCEPTS_H_
#if defined(__APPLE__) || defined(__OSX__)
int
fegetexcept
(
void
);
int
feenableexcept
(
unsigned
int
excepts
);
int
fedisableexcept
(
unsigned
int
excepts
);
#endif
#endif // EXCEPTS_H_
paddle/utils/Locks.cpp
0 → 100644
浏览文件 @
445d1e82
/* Copyright (c) 2016 Baidu, Inc. 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. */
#ifdef __APPLE__
#include <dispatch/dispatch.h>
#endif
#ifdef __APPLE__
#ifndef PTHREAD_BARRIER_H_
#define PTHREAD_BARRIER_H_
#include <pthread.h>
#include <errno.h>
typedef
int
pthread_barrierattr_t
;
typedef
struct
{
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
int
count
;
int
tripCount
;
}
pthread_barrier_t
;
int
pthread_barrier_init
(
pthread_barrier_t
*
barrier
,
const
pthread_barrierattr_t
*
attr
,
unsigned
int
count
)
{
if
(
count
==
0
)
{
errno
=
EINVAL
;
return
-
1
;
}
if
(
pthread_mutex_init
(
&
barrier
->
mutex
,
0
)
<
0
)
{
return
-
1
;
}
if
(
pthread_cond_init
(
&
barrier
->
cond
,
0
)
<
0
)
{
pthread_mutex_destroy
(
&
barrier
->
mutex
);
return
-
1
;
}
barrier
->
tripCount
=
count
;
barrier
->
count
=
0
;
return
0
;
}
int
pthread_barrier_destroy
(
pthread_barrier_t
*
barrier
)
{
pthread_cond_destroy
(
&
barrier
->
cond
);
pthread_mutex_destroy
(
&
barrier
->
mutex
);
return
0
;
}
int
pthread_barrier_wait
(
pthread_barrier_t
*
barrier
)
{
pthread_mutex_lock
(
&
barrier
->
mutex
);
++
(
barrier
->
count
);
if
(
barrier
->
count
>=
barrier
->
tripCount
)
{
barrier
->
count
=
0
;
pthread_cond_broadcast
(
&
barrier
->
cond
);
pthread_mutex_unlock
(
&
barrier
->
mutex
);
return
1
;
}
else
{
pthread_cond_wait
(
&
barrier
->
cond
,
&
(
barrier
->
mutex
));
pthread_mutex_unlock
(
&
barrier
->
mutex
);
return
0
;
}
}
#endif // PTHREAD_BARRIER_H_
typedef
int
pthread_spinlock_t
;
int
pthread_spin_init
(
pthread_spinlock_t
*
lock
,
int
pshared
)
{
__asm__
__volatile__
(
""
:::
"memory"
);
*
lock
=
0
;
return
0
;
}
int
pthread_spin_destroy
(
pthread_spinlock_t
*
lock
)
{
return
0
;
}
int
pthread_spin_lock
(
pthread_spinlock_t
*
lock
)
{
while
(
1
)
{
int
i
;
for
(
i
=
0
;
i
<
10000
;
i
++
)
{
if
(
__sync_bool_compare_and_swap
(
lock
,
0
,
1
))
{
return
0
;
}
}
sched_yield
();
}
}
int
pthread_spin_unlock
(
pthread_spinlock_t
*
lock
)
{
__asm__
__volatile__
(
""
:::
"memory"
);
*
lock
=
0
;
return
0
;
}
#endif // __APPLE__
paddle/utils/Locks.h
浏览文件 @
445d1e82
...
...
@@ -23,6 +23,50 @@ limitations under the License. */
#include <condition_variable>
#include <mutex>
#ifdef __APPLE__
#include <dispatch/dispatch.h>
#endif
#ifdef __APPLE__
#ifndef PTHREAD_BARRIER_H_
#define PTHREAD_BARRIER_H_
#include <pthread.h>
#include <errno.h>
typedef
int
pthread_barrierattr_t
;
typedef
struct
{
pthread_mutex_t
mutex
;
pthread_cond_t
cond
;
int
count
;
int
tripCount
;
}
pthread_barrier_t
;
extern
int
pthread_barrier_init
(
pthread_barrier_t
*
barrier
,
const
pthread_barrierattr_t
*
attr
,
unsigned
int
count
);
extern
int
pthread_barrier_destroy
(
pthread_barrier_t
*
barrier
);
extern
int
pthread_barrier_wait
(
pthread_barrier_t
*
barrier
);
#endif // PTHREAD_BARRIER_H_
typedef
int
pthread_spinlock_t
;
extern
int
pthread_spin_init
(
pthread_spinlock_t
*
lock
,
int
pshared
);
extern
int
pthread_spin_destroy
(
pthread_spinlock_t
*
lock
);
extern
int
pthread_spin_lock
(
pthread_spinlock_t
*
lock
);
extern
int
pthread_spin_unlock
(
pthread_spinlock_t
*
lock
);
#endif
namespace
paddle
{
/**
...
...
@@ -117,6 +161,29 @@ protected:
/**
* A simple wapper of semaphore which can only be shared in the same process.
*/
#ifdef __APPLE__
class
Semaphore
{
public:
explicit
Semaphore
(
int
initValue
=
0
)
{
sem_
=
dispatch_semaphore_create
(
initValue
);
}
~
Semaphore
()
{
dispatch_release
(
sem_
);
}
bool
timeWait
(
struct
timespec
*
ts
)
{
dispatch_time_t
m
=
dispatch_walltime
(
ts
,
0
);
return
(
0
==
dispatch_semaphore_wait
(
sem_
,
m
));
}
void
wait
()
{
dispatch_semaphore_wait
(
sem_
,
DISPATCH_TIME_FOREVER
);
}
void
post
()
{
dispatch_semaphore_signal
(
sem_
);}
protected:
dispatch_semaphore_t
sem_
;
};
#else
class
Semaphore
{
public:
/**
...
...
@@ -153,6 +220,8 @@ protected:
sem_t
sem_
;
};
#endif
static_assert
(
sizeof
(
SpinLock
)
==
64
,
"Wrong padding"
);
/**
...
...
paddle/utils/PythonUtil.h
浏览文件 @
445d1e82
...
...
@@ -18,6 +18,12 @@ limitations under the License. */
#ifndef PADDLE_NO_PYTHON
// must include the following two blocks, otherwise,
// gcc compiler may produce warning
#ifdef __APPLE__
#define _POSIX_SOURCE
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE 700
#endif
#ifdef _POSIX_C_SOURCE
#define __TEMP_POSIX_C_SOURCE _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
...
...
@@ -28,12 +34,14 @@ limitations under the License. */
#endif
#include <Python.h>
#include <frameobject.h>
#ifndef _POSIX_C_SOURCE
#warning "no _POSIX_C_SOURCE defined in Python.h"
#endif
#ifndef _XOPEN_SOURCE
#warning "no _XOPEN_SOURCE defined in Python.h"
#endif
// #ifndef _POSIX_C_SOURCE
// #warning "no _POSIX_C_SOURCE defined in Python.h"
// #endif
// #ifndef _XOPEN_SOURCE
// #warning "no _XOPEN_SOURCE defined in Python.h"
// #endif
#endif
#include "paddle/utils/Util.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录