提交 12e2402f 编写于 作者: L Liu Yiqun

Disable SpinLock and ThreadBarrier.

上级 2a601e02
...@@ -778,8 +778,10 @@ void testProjectionGrad(ProjectionConfig conf, ...@@ -778,8 +778,10 @@ void testProjectionGrad(ProjectionConfig conf,
config.biasSize = biasSize == 0 ? config.layerConfig.size() : biasSize; config.biasSize = biasSize == 0 ? config.layerConfig.size() : biasSize;
config.layerConfig.set_bias_size(config.biasSize); config.layerConfig.set_bias_size(config.biasSize);
config.layerConfig.set_shared_biases(sharedBias); config.layerConfig.set_shared_biases(sharedBias);
config.inputDefs.push_back( config.inputDefs.push_back({inputType,
{inputType, "layer_0", conf.input_size(), parameterSize}); "layer_0",
static_cast<size_t>(conf.input_size()),
parameterSize});
*config.layerConfig.add_inputs()->mutable_proj_conf() = conf; *config.layerConfig.add_inputs()->mutable_proj_conf() = conf;
config.testState = testState; config.testState = testState;
testLayerGrad(config, "mixed", batchSize, false, useGpu); testLayerGrad(config, "mixed", batchSize, false, useGpu);
......
...@@ -111,7 +111,7 @@ int getrf<double>(const CBLAS_ORDER order, ...@@ -111,7 +111,7 @@ int getrf<double>(const CBLAS_ORDER order,
return LAPACKE_dgetrf(order, M, N, A, lda, ipiv); return LAPACKE_dgetrf(order, M, N, A, lda, ipiv);
#endif #endif
#else #else
LOG(FATAL) << "Not implemented". LOG(FATAL) << "Not implemented";
#endif #endif
return 0; return 0;
} }
...@@ -129,7 +129,7 @@ int getri<float>(const CBLAS_ORDER order, ...@@ -129,7 +129,7 @@ int getri<float>(const CBLAS_ORDER order,
return LAPACKE_sgetri(order, N, A, lda, ipiv); return LAPACKE_sgetri(order, N, A, lda, ipiv);
#endif #endif
#else #else
LOG(FATAL) << "Not implemented". LOG(FATAL) << "Not implemented";
#endif #endif
return 0; return 0;
} }
...@@ -147,7 +147,7 @@ int getri<double>(const CBLAS_ORDER order, ...@@ -147,7 +147,7 @@ int getri<double>(const CBLAS_ORDER order,
return LAPACKE_dgetri(order, N, A, lda, ipiv); return LAPACKE_dgetri(order, N, A, lda, ipiv);
#endif #endif
#else #else
LOG(FATAL) << "Not implemented". LOG(FATAL) << "Not implemented";
#endif #endif
return 0; return 0;
} }
......
...@@ -38,34 +38,68 @@ void Semaphore::post() { sem_post(&m->sem); } ...@@ -38,34 +38,68 @@ void Semaphore::post() { sem_post(&m->sem); }
class SpinLockPrivate { class SpinLockPrivate {
public: public:
inline SpinLockPrivate() { pthread_spin_init(&lock_, 0); } inline SpinLockPrivate() {
inline ~SpinLockPrivate() { pthread_spin_destroy(&lock_); } #ifndef __ANDROID__
pthread_spin_init(&lock_, 0);
#else
lock_ = 0;
#endif
}
inline ~SpinLockPrivate() {
#ifndef __ANDROID__
pthread_spin_destroy(&lock_);
#endif
}
#ifndef __ANDROID__
pthread_spinlock_t lock_; pthread_spinlock_t lock_;
char padding_[64 - sizeof(pthread_spinlock_t)]; #else
unsigned long lock_;
#endif
char padding_[64 - sizeof(lock_)];
}; };
SpinLock::SpinLock() : m(new SpinLockPrivate()) {} SpinLock::SpinLock() : m(new SpinLockPrivate()) {}
SpinLock::~SpinLock() { delete m; } SpinLock::~SpinLock() { delete m; }
void SpinLock::lock() { pthread_spin_lock(&m->lock_); } void SpinLock::lock() {
#ifndef __ANDROID__
pthread_spin_lock(&m->lock_);
#endif
}
void SpinLock::unlock() { pthread_spin_unlock(&m->lock_); } void SpinLock::unlock() {
#ifndef __ANDROID__
pthread_spin_unlock(&m->lock_);
#endif
}
class ThreadBarrierPrivate { class ThreadBarrierPrivate {
public: public:
#ifndef __ANDROID__
pthread_barrier_t barrier_; pthread_barrier_t barrier_;
#else
unsigned long barrier_;
#endif
}; };
ThreadBarrier::ThreadBarrier(int count) : m(new ThreadBarrierPrivate()) { ThreadBarrier::ThreadBarrier(int count) : m(new ThreadBarrierPrivate()) {
#ifndef __ANDROID__
pthread_barrier_init(&m->barrier_, nullptr, count); pthread_barrier_init(&m->barrier_, nullptr, count);
#endif
} }
ThreadBarrier::~ThreadBarrier() { ThreadBarrier::~ThreadBarrier() {
#ifndef __ANDROID__
pthread_barrier_destroy(&m->barrier_); pthread_barrier_destroy(&m->barrier_);
#endif
delete m; delete m;
} }
void ThreadBarrier::wait() { pthread_barrier_wait(&m->barrier_); } void ThreadBarrier::wait() {
#ifndef __ANDROID__
pthread_barrier_wait(&m->barrier_);
#endif
}
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册