diff options
author | Yangqing Jia <jiayq@google.com> | 2014-07-23 22:47:25 -0700 |
---|---|---|
committer | Yangqing Jia <jiayq@google.com> | 2014-07-23 22:47:25 -0700 |
commit | 15bc0f767fa0b8f12302f81e86654bd11daf8bea (patch) | |
tree | fcb579f4a3e01cc8f241f116622e3cd744ec8d9d | |
parent | 7683986be557fe9d6f44ec1cdd6a2cfd889c07ed (diff) | |
download | caffeonacl-15bc0f767fa0b8f12302f81e86654bd11daf8bea.tar.gz caffeonacl-15bc0f767fa0b8f12302f81e86654bd11daf8bea.tar.bz2 caffeonacl-15bc0f767fa0b8f12302f81e86654bd11daf8bea.zip |
add gflags dependency to caffe.
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | include/caffe/common.hpp | 4 | ||||
-rw-r--r-- | src/caffe/common.cpp | 57 |
3 files changed, 41 insertions, 24 deletions
@@ -155,8 +155,8 @@ ifneq ($(CPU_ONLY), 1) LIBRARY_DIRS += $(CUDA_LIB_DIR) LIBRARIES := cudart cublas curand endif -LIBRARIES += pthread \ - glog protobuf leveldb snappy \ +LIBRARIES += \ + glog gflags pthread protobuf leveldb snappy \ lmdb \ boost_system \ hdf5_hl hdf5 \ diff --git a/include/caffe/common.hpp b/include/caffe/common.hpp index 2c79f2bc..ff8649ad 100644 --- a/include/caffe/common.hpp +++ b/include/caffe/common.hpp @@ -80,6 +80,10 @@ using std::set; using std::string; using std::vector; +// A global initialization function that you should call in your main function. +// Currently it initializes google flags and google logging. +void GlobalInit(int* pargc, char*** pargv); + // A singleton class to hold common caffe stuff, such as the handler that // caffe is going to use for cublas, curand, etc. class Caffe { diff --git a/src/caffe/common.cpp b/src/caffe/common.cpp index e8765eeb..5894a961 100644 --- a/src/caffe/common.cpp +++ b/src/caffe/common.cpp @@ -1,11 +1,14 @@ // Copyright 2014 BVLC and contributors. +#include <gflags/gflags.h> +#include <glog/logging.h> #include <cstdio> #include <ctime> #include "caffe/common.hpp" #include "caffe/util/rng.hpp" + namespace caffe { shared_ptr<Caffe> Caffe::singleton_; @@ -19,6 +22,14 @@ int64_t cluster_seedgen(void) { return seed; } + +void GlobalInit(int* pargc, char*** pargv) { + // Google flags. + ::gflags::ParseCommandLineFlags(pargc, pargv, true); + // Google logging. + ::google::InitGoogleLogging(*(pargv)[0]); +} + #ifdef CPU_ONLY // CPU-only Caffe. Caffe::Caffe() @@ -138,28 +149,30 @@ void Caffe::DeviceQuery() { return; } CUDA_CHECK(cudaGetDeviceProperties(&prop, device)); - printf("Device id: %d\n", device); - printf("Major revision number: %d\n", prop.major); - printf("Minor revision number: %d\n", prop.minor); - printf("Name: %s\n", prop.name); - printf("Total global memory: %lu\n", prop.totalGlobalMem); - printf("Total shared memory per block: %lu\n", prop.sharedMemPerBlock); - printf("Total registers per block: %d\n", prop.regsPerBlock); - printf("Warp size: %d\n", prop.warpSize); - printf("Maximum memory pitch: %lu\n", prop.memPitch); - printf("Maximum threads per block: %d\n", prop.maxThreadsPerBlock); - printf("Maximum dimension of block: %d, %d, %d\n", - prop.maxThreadsDim[0], prop.maxThreadsDim[1], prop.maxThreadsDim[2]); - printf("Maximum dimension of grid: %d, %d, %d\n", - prop.maxGridSize[0], prop.maxGridSize[1], prop.maxGridSize[2]); - printf("Clock rate: %d\n", prop.clockRate); - printf("Total constant memory: %lu\n", prop.totalConstMem); - printf("Texture alignment: %lu\n", prop.textureAlignment); - printf("Concurrent copy and execution: %s\n", - (prop.deviceOverlap ? "Yes" : "No")); - printf("Number of multiprocessors: %d\n", prop.multiProcessorCount); - printf("Kernel execution timeout: %s\n", - (prop.kernelExecTimeoutEnabled ? "Yes" : "No")); + LOG(INFO) << "Device id: " << device; + LOG(INFO) << "Major revision number: " << prop.major; + LOG(INFO) << "Minor revision number: " << prop.minor; + LOG(INFO) << "Name: " << prop.name; + LOG(INFO) << "Total global memory: " << prop.totalGlobalMem; + LOG(INFO) << "Total shared memory per block: " << prop.sharedMemPerBlock; + LOG(INFO) << "Total registers per block: " << prop.regsPerBlock; + LOG(INFO) << "Warp size: " << prop.warpSize; + LOG(INFO) << "Maximum memory pitch: " << prop.memPitch; + LOG(INFO) << "Maximum threads per block: " << prop.maxThreadsPerBlock; + LOG(INFO) << "Maximum dimension of block: " + << prop.maxThreadsDim[0] << ", " << prop.maxThreadsDim[1] << ", " + << prop.maxThreadsDim[2]; + LOG(INFO) << "Maximum dimension of grid: " + << prop.maxGridSize[0] << ", " << prop.maxGridSize[1] << ", " + << prop.maxGridSize[2]; + LOG(INFO) << "Clock rate: " << prop.clockRate; + LOG(INFO) << "Total constant memory: " << prop.totalConstMem; + LOG(INFO) << "Texture alignment: " << prop.textureAlignment; + LOG(INFO) << "Concurrent copy and execution: " + << (prop.deviceOverlap ? "Yes" : "No"); + LOG(INFO) << "Number of multiprocessors: " << prop.multiProcessorCount; + LOG(INFO) << "Kernel execution timeout: " + << (prop.kernelExecTimeoutEnabled ? "Yes" : "No"); return; } |