| 77 | |
| 78 | template <typename Dtype> |
| 79 | void BasePrefetchingDataLayer<Dtype>::InternalThreadEntry() { |
| 80 | #ifndef CPU_ONLY |
| 81 | cudaStream_t stream; |
| 82 | if (Caffe::mode() == Caffe::GPU) { |
| 83 | CUDA_CHECK(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking)); |
| 84 | } |
| 85 | #endif |
| 86 | |
| 87 | try { |
| 88 | while (!must_stop()) { |
| 89 | Batch<Dtype>* batch = prefetch_free_.pop(); |
| 90 | load_batch(batch); |
| 91 | #ifndef CPU_ONLY |
| 92 | if (Caffe::mode() == Caffe::GPU) { |
| 93 | batch->data_.data().get()->async_gpu_push(stream); |
| 94 | if (this->output_labels_) { |
| 95 | batch->label_.data().get()->async_gpu_push(stream); |
| 96 | } |
| 97 | CUDA_CHECK(cudaStreamSynchronize(stream)); |
| 98 | } |
| 99 | #endif |
| 100 | prefetch_full_.push(batch); |
| 101 | } |
| 102 | } catch (boost::thread_interrupted&) { |
| 103 | // Interrupted exception is expected on shutdown |
| 104 | } |
| 105 | #ifndef CPU_ONLY |
| 106 | if (Caffe::mode() == Caffe::GPU) { |
| 107 | CUDA_CHECK(cudaStreamDestroy(stream)); |
| 108 | } |
| 109 | #endif |
| 110 | } |
| 111 | |
| 112 | template <typename Dtype> |
| 113 | void BasePrefetchingDataLayer<Dtype>::Forward_cpu( |
nothing calls this directly
no test coverage detected