pytorch/caffe2/utils/threadpool/pthreadpool_impl.cc
Marat Dukhan d3651585b8
Simplify pthreadpool implementation on top of Caffe2 thread pool (#7666)
Remove one layer of pointer dereference when calling the thread pool.
2018-06-18 19:06:50 -07:00

24 lines
606 B
C++

#include "caffe2/utils/threadpool/pthreadpool.h"
#include "caffe2/utils/threadpool/ThreadPool.h"
//
// External API
//
void pthreadpool_compute_1d(
pthreadpool_t threadpool,
pthreadpool_function_1d_t function,
void* argument,
size_t range) {
reinterpret_cast<caffe2::ThreadPool*>(threadpool)
->run(
[function, argument](int threadId, size_t workId) {
function(argument, workId);
},
range);
}
size_t pthreadpool_get_threads_count(pthreadpool_t threadpool) {
return reinterpret_cast<caffe2::ThreadPool*>(threadpool)->getNumThreads();
}