• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ CURAND_CHECK函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CURAND_CHECK函数的典型用法代码示例。如果您正苦于以下问题:C++ CURAND_CHECK函数的具体用法?C++ CURAND_CHECK怎么用?C++ CURAND_CHECK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CURAND_CHECK函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CURAND_CHECK

void Caffe::set_random_seed(const unsigned int seed) {
  if (Caffe::GetDefaultDeviceContext()->backend() == BACKEND_CUDA) {
#ifdef USE_CUDA
    // Curand seed
    static bool g_curand_availability_logged = false;
    if (Get().curand_generator_) {
      CURAND_CHECK(
          curandSetPseudoRandomGeneratorSeed(curand_generator(), seed));
      CURAND_CHECK(curandSetGeneratorOffset(curand_generator(), 0));
    } else {
      if (!g_curand_availability_logged) {
        LOG(ERROR)<<
        "Curand not available. Skipping setting the curand seed.";
        g_curand_availability_logged = true;
      }
    }
#endif  // USE_CUDA
  } else {
#ifdef USE_GREENTEA
// TODO: Proper RNG and Seed for OpenCL
#endif  // USE_GREENTEA
  }
  // RNG seed
  Get().random_generator_.reset(new RNG(seed));
}
开发者ID:aharrison24,项目名称:caffe,代码行数:25,代码来源:common.cpp


示例2: CUDA_CHECK

void Caffe::SetDevice(const int device_id) {
  int current_device;
  CUDA_CHECK(cudaGetDevice(&current_device));
  if (current_device == device_id) {
    return;
  }
  // The call to cudaSetDevice must come before any calls to Get, which
  // may perform initialization using the GPU.
  CUDA_CHECK(cudaSetDevice(device_id));
  if (Get().cublas_handle_) CUBLAS_CHECK(cublasDestroy(Get().cublas_handle_));
  if (Get().cusparse_descr_)CUSPARSE_CHECK(cusparseDestroyMatDescr(Get().cusparse_descr_));
  if (Get().cusparse_handle_)CUSPARSE_CHECK(cusparseDestroy(Get().cusparse_handle_));
  if (Get().curand_generator_) {
    CURAND_CHECK(curandDestroyGenerator(Get().curand_generator_));
  }
  CUSPARSE_CHECK(cusparseCreate(&Get().cusparse_handle_));
  CUSPARSE_CHECK(cusparseCreateMatDescr(&Get().cusparse_descr_));
//  cusparseSetMatType(cusparse_descr_,CUSPARSE_MATRIX_TYPE_GENERAL);
//  cusparseSetMatIndexBase(cusparse_descr_,CUSPARSE_INDEX_BASE_ZERO);
  LOG(INFO)<<"set descr";
  CUBLAS_CHECK(cublasCreate(&Get().cublas_handle_));
  CURAND_CHECK(curandCreateGenerator(&Get().curand_generator_,
      CURAND_RNG_PSEUDO_DEFAULT));
  CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(Get().curand_generator_,
      cluster_seedgen()));
}
开发者ID:ZhouYuSong,项目名称:caffe-pruned,代码行数:26,代码来源:common.cpp


示例3: if

void Caffe::set_random_seed(uint64_t random_seed) {
  if (root_seed_.load() == Caffe::SEED_NOT_SET) {
    root_seed_.store(random_seed);
  } else if (random_seed == Caffe::SEED_NOT_SET) {
    return;  // i.e. root solver was previously set to 0+ and there is no need to re-generate
  }
#ifndef CPU_ONLY
  {
    // Curand seed
    std::lock_guard<std::mutex> lock(seed_mutex_);
    if (random_seed == Caffe::SEED_NOT_SET) {
      random_seed = cluster_seedgen();
    }
    static bool g_curand_availability_logged = false;
    curandGenerator_t curand_generator_handle = curand_generator();
    if (curand_generator_handle) {
      CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(curand_generator_handle, random_seed));
      CURAND_CHECK(curandSetGeneratorOffset(curand_generator_handle, 0));
    } else if (!g_curand_availability_logged) {
      LOG(ERROR) << "Curand not available. Skipping setting the curand seed.";
      g_curand_availability_logged = true;
    }
  }
#endif
  // RNG seed
  Get().random_generator_.reset(new RNG(random_seed));
}
开发者ID:Caffe-MPI,项目名称:Caffe-MPI.github.io,代码行数:27,代码来源:common.cpp


示例4: CURAND_CHECK

void Caffe::set_random_seed(unsigned int seed)
{
  CURAND_CHECK(curandDestroyGenerator(Get().curand_generator_));
  CURAND_CHECK(curandCreateGenerator(&Get().curand_generator_, CURAND_RNG_PSEUDO_DEFAULT));
  CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(Get().curand_generator_, seed));
  VSL_CHECK(vslDeleteStream(&Get().vsl_stream_));
  VSL_CHECK(vslNewStream(&Get().vsl_stream_, VSL_BRNG_MT19937, seed));
}
开发者ID:xiaobinxu,项目名称:recaffe,代码行数:8,代码来源:common.cpp


示例5: mode_

Caffe::Caffe()
  : mode_(Caffe::CPU), phase_(Caffe::TRAIN), cublas_handle_(NULL),
  curand_generator_(NULL), vsl_stream_(NULL)
{
  CUBLAS_CHECK(cublasCreate(&cublas_handle_));
  //TODO: original caffe code has bug here!
  CURAND_CHECK(curandCreateGenerator(&curand_generator_, CURAND_RNG_PSEUDO_DEFAULT));
  CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(curand_generator_, 1701ULL));
  VSL_CHECK(vslNewStream(&vsl_stream_, VSL_BRNG_MT19937, 1701));
}
开发者ID:xiaobinxu,项目名称:recaffe,代码行数:10,代码来源:common.cpp


示例6: TEST_F

TEST_F(CommonTest, TestRandSeedGPU) {
  SyncedMemory data_a(10 * sizeof(unsigned int));
  SyncedMemory data_b(10 * sizeof(unsigned int));
  Caffe::set_random_seed(1701);
  CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
        static_cast<unsigned int*>(data_a.mutable_gpu_data()), 10));
  Caffe::set_random_seed(1701);
  CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
        static_cast<unsigned int*>(data_b.mutable_gpu_data()), 10));
  for (int i = 0; i < 10; ++i) {
    EXPECT_EQ(((const unsigned int*)(data_a.cpu_data()))[i],
        ((const unsigned int*)(data_b.cpu_data()))[i]);
  }
}
开发者ID:105,项目名称:caffe,代码行数:14,代码来源:test_common.cpp


示例7: CURAND_CHECK

void Caffe::set_random_seed(const unsigned int seed) {
  // Curand seed
  // Yangqing's note: simply setting the generator seed does not seem to
  // work on the tesla K20s, so I wrote the ugly reset thing below.
  if (Get().curand_generator_) {
    CURAND_CHECK(curandDestroyGenerator(curand_generator()));
    CURAND_CHECK(curandCreateGenerator(&Get().curand_generator_,
        CURAND_RNG_PSEUDO_DEFAULT));
    CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(curand_generator(),
        seed));
  } else {
    LOG(ERROR) << "Curand not available. Skipping setting the curand seed.";
  }
  // RNG seed
  Get().random_generator_.reset(new RNG(seed));
}
开发者ID:FuchenUSTC,项目名称:caffe-c3d,代码行数:16,代码来源:common.cpp


示例8: CURAND_CHECK

//	implements for CPU/GPU Manager
void Dragon::set_random_seed(const unsigned int seed) {
	// Curand seed
	static bool g_curand_availability_logged = false;
	if (get_curand_generator()) {
		CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(get_curand_generator(), seed));
		CURAND_CHECK(curandSetGeneratorOffset(get_curand_generator(), 0));
	}
	else {
		if (!g_curand_availability_logged) {
			LOG(ERROR) <<"Curand not available. Skipping setting the curand seed.";
			g_curand_availability_logged = true;
		}
	}
	// RNG seed
	Get().random_generator.reset(new RNG(seed));
}
开发者ID:qianxinchun,项目名称:Dragon,代码行数:17,代码来源:common.cpp


示例9: CUDA_CHECK

void Caffe::SetDevice(const int device_id) {
  int current_device;
  CUDA_CHECK(cudaGetDevice(&current_device));
  if (current_device == device_id) {
    return;
  }
  if (Get().cublas_handle_) CUBLAS_CHECK(cublasDestroy(Get().cublas_handle_));
  if (Get().curand_generator_) {
    CURAND_CHECK(curandDestroyGenerator(Get().curand_generator_));
  }
  CUDA_CHECK(cudaSetDevice(device_id));
  CUBLAS_CHECK(cublasCreate(&Get().cublas_handle_));
  CURAND_CHECK(curandCreateGenerator(&Get().curand_generator_,
      CURAND_RNG_PSEUDO_DEFAULT));
  CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(Get().curand_generator_,
      cluster_seedgen()));
}
开发者ID:FuchenUSTC,项目名称:caffe-c3d,代码行数:17,代码来源:common.cpp


示例10: CURAND_CHECK

Caffe::~Caffe() {
  if (cusparse_descr_) CUSPARSE_CHECK(cusparseDestroyMatDescr(cusparse_descr_));
  if (cublas_handle_) CUBLAS_CHECK(cublasDestroy(cublas_handle_));
  if (cusparse_handle_) CUSPARSE_CHECK(cusparseDestroy(cusparse_handle_));
  if (curand_generator_) {
    CURAND_CHECK(curandDestroyGenerator(curand_generator_));
  }
}
开发者ID:ZhouYuSong,项目名称:caffe-pruned,代码行数:8,代码来源:common.cpp


示例11: CUBLAS_CHECK

Caffe::~Caffe()
{
  if (cublas_handle_)
    CUBLAS_CHECK(cublasDestroy(cublas_handle_));
  if (curand_generator_)
    CURAND_CHECK(curandDestroyGenerator(curand_generator_));
  if (vsl_stream_)
    VSL_CHECK(vslDeleteStream(&vsl_stream_));
}
开发者ID:xiaobinxu,项目名称:recaffe,代码行数:9,代码来源:common.cpp


示例12: CUDA_CHECK

void Engine::SetDevice(const int device_id) {
  int current_device;
  CUDA_CHECK(cudaGetDevice(&current_device));
  if (current_device == device_id) {
    return;
  }
  // The call to cudaSetDevice must come before any calls to Get, which
  // may perform initialization using the GPU.
  CUDA_CHECK(cudaSetDevice(device_id));
  if (Get().cublas_handle_) CUBLAS_CHECK(cublasDestroy(Get().cublas_handle_));
  if (Get().curand_generator_) {
    CURAND_CHECK(curandDestroyGenerator(Get().curand_generator_));
  }
  CUBLAS_CHECK(cublasCreate(&Get().cublas_handle_));
  CURAND_CHECK(curandCreateGenerator(&Get().curand_generator_,
      CURAND_RNG_PSEUDO_DEFAULT));
  CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(Get().curand_generator_,
      cluster_seedgen()));
}
开发者ID:airxcy,项目名称:ITF_Tracker,代码行数:19,代码来源:common.cpp


示例13: CUBLAS_CHECK

Caffe::~Caffe() {
  // Make sure all device contexts and
  // dependent memory blocks are freed properly
  device_contexts_.clear();
#ifdef USE_CUDA
  if (cublas_handle_)
    CUBLAS_CHECK(cublasDestroy(cublas_handle_));
  if (curand_generator_) {
    CURAND_CHECK(curandDestroyGenerator(curand_generator_));
  }
#endif  // USE_CUDA
}
开发者ID:aharrison24,项目名称:caffe,代码行数:12,代码来源:common.cpp


示例14: TEST_F

TEST_F(CommonTest, TestRandSeedGPU) {
  device *dc = Caffe::GetDefaultDevice();

  if (dc->backend() == BACKEND_CUDA) {
#ifdef USE_CUDA
    SyncedMemory data_a(10 * sizeof(unsigned int),
                        Caffe::GetDefaultDevice());
    SyncedMemory data_b(10 * sizeof(unsigned int),
                        Caffe::GetDefaultDevice());
    Caffe::set_random_seed(1701, Caffe::GetDefaultDevice());
    CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
          static_cast<unsigned int*>(data_a.mutable_gpu_data()), 10));
    Caffe::set_random_seed(1701, Caffe::GetDefaultDevice());
    CURAND_CHECK(curandGenerate(Caffe::curand_generator(),
          static_cast<unsigned int*>(data_b.mutable_gpu_data()), 10));
    for (int i = 0; i < 10; ++i) {
      EXPECT_EQ(((const unsigned int*)(data_a.cpu_data()))[i],
          ((const unsigned int*)(data_b.cpu_data()))[i]);
    }
#endif  // USE_CUDA
  }
}
开发者ID:ifp-uiuc,项目名称:caffe,代码行数:22,代码来源:test_common.cpp


示例15: CUDA_CHECK

void Caffe::SetSlaveDevice(const int slave_device_id) {
  int current_device;
  CUDA_CHECK(cudaGetDevice(&current_device));
  if (current_device == slave_device_id) {
    return;
  }
  if (Get().slave_cublas_handle_) CUBLAS_CHECK(cublasDestroy(Get().slave_cublas_handle_));
  if (Get().slave_curand_generator_) {
    CURAND_CHECK(curandDestroyGenerator(Get().slave_curand_generator_));
  }
  CUDA_CHECK(cudaSetDevice(slave_device_id));
  CUDA_CHECK(cudaStreamCreate (&Get().slave_cu_stream_));
  CUBLAS_CHECK(cublasCreate(&Get().slave_cublas_handle_));
  CUBLAS_CHECK(cublasSetStream(Get().slave_cublas_handle_, Get().slave_cu_stream_));
  CURAND_CHECK(curandCreateGenerator(&Get().slave_curand_generator_,
      CURAND_RNG_PSEUDO_DEFAULT));
  CURAND_CHECK(curandSetPseudoRandomGeneratorSeed(Get().slave_curand_generator_,
      cluster_seedgen()));
  Get().slave_device_id_ = slave_device_id;
  CUDA_CHECK(cudaSetDevice(current_device));
  Caffe::set_gpu_mode(Caffe::MASTER_SLAVE);
}
开发者ID:SophieZhou,项目名称:caffe-multilabel,代码行数:22,代码来源:common.cpp


示例16: Get

void Caffe::SetDevice(const int device_id) {
  std::vector<int> devices;
  devices.push_back(device_id);
  Caffe::SetDevices(devices);

  Get().default_device_context_ = GetDeviceContext(device_id);

  if (Get().default_device_context_->backend() == Backend::BACKEND_CUDA) {
#ifdef USE_CUDA
    int current_device;
    CUDA_CHECK(cudaGetDevice(&current_device));
    if (current_device == device_id) {
      return;
    }
// The call to cudaSetDevice must come before any calls to Get, which
// may perform initialization using the GPU.
    CUDA_CHECK(cudaSetDevice(device_id));
    if (Get().cublas_handle_)
      CUBLAS_CHECK(cublasDestroy(Get().cublas_handle_));
    if (Get().curand_generator_) {
      CURAND_CHECK(curandDestroyGenerator(Get().curand_generator_));
    }
    CUBLAS_CHECK(cublasCreate(&Get().cublas_handle_));
    CURAND_CHECK(
        curandCreateGenerator(&Get().curand_generator_,
                              CURAND_RNG_PSEUDO_DEFAULT));
    CURAND_CHECK(
        curandSetPseudoRandomGeneratorSeed(Get().curand_generator_,
                                           cluster_seedgen()));
#endif  // USE_CUDA
  } else {
#ifdef USE_GREENTEA
#ifdef USE_CLBLAS
    clblasSetup();
#endif  // USE_CLBLAS
#endif  // USE_GREENTEA
  }
}
开发者ID:aharrison24,项目名称:caffe,代码行数:38,代码来源:common.cpp


示例17: CUBLAS_CHECK

Caffe::~Caffe() {
  for (vector<cublasHandle_t>& group_cublas_handles : cublas_handles_) {
    for (cublasHandle_t h : group_cublas_handles) {
      if (h) {
        CUBLAS_CHECK(cublasDestroy(h));
      }
    }
  }
  for_each(curand_generators_.begin(), curand_generators_.end(), [](curandGenerator_t h) {
    if (h) {
      CURAND_CHECK(curandDestroyGenerator(h));
    }
  });
}
开发者ID:Caffe-MPI,项目名称:Caffe-MPI.github.io,代码行数:14,代码来源:common.cpp


示例18: CURAND_CHECK

Engine::~Engine() {
  if (cublas_handle_) CUBLAS_CHECK(cublasDestroy(cublas_handle_));
  if (curand_generator_) {
    CURAND_CHECK(curandDestroyGenerator(curand_generator_));
  }
}
开发者ID:airxcy,项目名称:ITF_Tracker,代码行数:6,代码来源:common.cpp



注:本文中的CURAND_CHECK函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CURSOR_API_CALL函数代码示例发布时间:2022-05-30
下一篇:
C++ CUDNN_CHECK函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap