[caffe]prerequisites

http://blog.csdn.net/apsvvfb/article/details/50547718

  1. CUDA

1.CUDA

1) functions

cudaError_t cudaMemcpyAsync( void * dst,
const void * src,
size_t count,
enum cudaMemcpyKind kind,
cudaStream_t stream = 0
)

Copies count bytes from the memory area pointed to by src to the memory area pointed to by dst, where kind is one of cudaMemcpyHostToHost, cudaMemcpyHostToDevice, cudaMemcpyDeviceToHost, or cudaMemcpyDeviceToDevice, and specifies the direction of the copy. The memory areas may not overlap. Calling cudaMemcpyAsync() with dst and src pointers that do not match the direction of the copy results in an undefined behavior.

cudaMemcpyAsync() is asynchronous with respect to the host, so the call may return before the copy is complete. It only works on page-locked host memory and returns an error if a pointer to pageable memory is passed as input. The copy can optionally be associated to a stream by passing a non-zero stream argument. If kind is cudaMemcpyHostToDevice or cudaMemcpyDeviceToHost and the stream is non-zero, the copy may overlap with operations in other streams.

Parameters:
dst - Destination memory address
src - Source memory address
count - Size in bytes to copy
kind - Type of transfer
stream - Stream identifier

cudaError_t cudaStreamSynchronize ( cudaStream_t stream )

Blocks until stream has completed all operations. If the cudaDeviceBlockingSync flag was set for this device, the host thread will block until the stream is finished with all of its tasks.

Parameters:
stream - Stream identifier

Returns:
cudaSuccess, cudaErrorInvalidResourceHandle

Note:
Note that this function may also return error codes from previous, asynchronous launches.**

//to be continued

2.BOOST

1) thread_specific_ptr

http://blog.csdn.net/apsvvfb/article/details/50542863

2) shared_ptr

shared_ptr的reset()函数是将引用计数减1,停止对指针的共享,除非引用计数为0,否则不会发生删除操作。带参数的reset()则类似相同形式的构造函数,原指针引用计数减1的同时改为管理另外一个指针。

3) mutex (caffe的blocking_queue.cpp中定义了一个class)

http://zh.highscore.de/cpp/boost/multithreading.html
i)boost::condition_variable
The classes condition_variable and condition_variable_any provide a mechanism for one thread to wait for notification from another thread that a particular condition has become true. The general usage pattern is that one thread locks a mutex and then calls wait on an instance of condition_variable or condition_variable_any. When the thread is woken from the wait, then it checks to see if the appropriate condition is now true, and continues if so. If the condition is not true, then the thread then calls wait again to resume waiting.

function: notify_one()
If any threads are currently blocked waiting on *this in a call to wait or timed_wait, unblocks one of those threads.

ii)boost::mutex
http://www.cppblog.com/ming81/archive/2012/07/18/184028.html
iii)boost::mutex::scoped_lock lock 独占锁

你可能感兴趣的:([caffe]prerequisites)