示例#1
0
void BasePrefetchingDataLayer<Dtype>::LayerSetUp(
    const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
  BaseDataLayer<Dtype>::LayerSetUp(bottom, top);
  // Before starting the prefetch thread, we make cpu_data and gpu_data
  // calls so that the prefetch thread does not accidentally make simultaneous
  // cudaMalloc calls when the main thread is running. In some GPUs this
  // seems to cause failures if we do not so.
  for (int i = 0; i < PREFETCH_COUNT; ++i) {
    prefetch_[i].data_.mutable_cpu_data();
    if (this->output_labels_) {
      prefetch_[i].label_.mutable_cpu_data();
    }
  }
#ifndef CPU_ONLY
  if (Caffe::mode() == Caffe::GPU) {
    for (int i = 0; i < PREFETCH_COUNT; ++i) {
      prefetch_[i].data_.mutable_gpu_data();
      if (this->output_labels_) {
        prefetch_[i].label_.mutable_gpu_data();
      }
    }
  }
#endif
  DLOG(INFO) << "Initializing prefetch";
  this->data_transformer_->InitRand();
  StartInternalThread();
  DLOG(INFO) << "Prefetch initialized.";
}
示例#2
0
RDMAAdapter::RDMAAdapter()
    : context_(open_default_device()),
      pd_(alloc_protection_domain(context_)) {
  channel_ = ibv_create_comp_channel(context_);
  CHECK(channel_) << "Failed to create completion channel";
  cq_ = ibv_create_cq(context_, MAX_CONCURRENT_WRITES * 2, NULL, channel_, 0);
  CHECK(cq_) << "Failed to create completion queue";
  CHECK(!ibv_req_notify_cq(cq_, 0)) << "Failed to request CQ notification";

  StartInternalThread();
}
void BasePrefetchingDataLayer<Ftype, Btype>::LayerSetUp(const vector<Blob*>& bottom,
    const vector<Blob*>& top) {
  this->rank_ = this->solver_rank_;
  bottom_init_ = bottom;
  top_init_ = top;
  BaseDataLayer<Ftype, Btype>::LayerSetUp(bottom, top);
  const Solver* psolver = this->parent_solver();
  const uint64_t random_seed = (psolver == nullptr ||
      static_cast<uint64_t>(psolver->param().random_seed()) == Caffe::SEED_NOT_SET) ?
          Caffe::next_seed() : static_cast<uint64_t>(psolver->param().random_seed());
  StartInternalThread(false, random_seed);
}
template<typename Dtype> void TransformingFastHDF5InputLayer<Dtype>::
LayerSetUp(const vector<Blob<Dtype>*>& b, const vector<Blob<Dtype>*>& t) {
  int batch_size = this->layer_param_.fast_hdf5_input_param().batch_size();

  for (int i = 0; i < PREFETCH_COUNT; i++) {
    prefetch_[i].blobs_.resize(batch_size);
    for (int j = 0; j < batch_size; j++) {
      prefetch_[i].blobs_[j].resize(t.size());
      for (int k = 0; k < t.size(); k++)
        prefetch_[i].blobs_[j][k] = new Blob<Dtype>();
    }
    prefetch_free_.push(prefetch_ + i);
  }
  tmp_.resize(t.size());
  for (int i = 0; i < tmp_.size(); i++)
    tmp_[i] = new Blob<Dtype>();
  input_layer_->LayerSetUp(b, tmp_);
  transformation_layer_->LayerSetUp(tmp_, prefetch_[0].blobs_[0]);
  StartInternalThread();
}
void BasePrefetchingDataLayer<Dtype>::CreatePrefetchThread() {
  this->phase_ = Caffe::phase();
  this->data_transformer_.InitRand();
  CHECK(StartInternalThread()) << "Thread execution failed";
}
示例#6
0
 void BasePrefetchingProducer::CreatePrefetchThread() {
   CHECK(StartInternalThread()) << "Thread execution failed";
 }
int ConnectionIOServer::start() {
    if (pipe2(pipefd_, O_NONBLOCK) == -1) {          
        return -1;    
    }        
    return StartInternalThread();        
}