diff options
author | Eric Tzeng <eric.s.tzeng@gmail.com> | 2014-02-27 16:08:16 -0800 |
---|---|---|
committer | Eric Tzeng <eric.s.tzeng@gmail.com> | 2014-03-13 14:30:44 -0700 |
commit | 8bc83b07dbb5548aa73c55a21596ce35f2a9b141 (patch) | |
tree | 35562afaa464bc8f936981d9e1c6999c02ef2f2f /src | |
parent | 04d6595d3c5995999675bbf1abb59b5f5305a2ec (diff) | |
download | caffeonacl-8bc83b07dbb5548aa73c55a21596ce35f2a9b141.tar.gz caffeonacl-8bc83b07dbb5548aa73c55a21596ce35f2a9b141.tar.bz2 caffeonacl-8bc83b07dbb5548aa73c55a21596ce35f2a9b141.zip |
Compile a binary to run all tests at once.
Diffstat (limited to 'src')
-rw-r--r-- | src/caffe/test/test_caffe_main.cpp | 32 | ||||
-rw-r--r-- | src/caffe/test/test_caffe_main.hpp | 28 |
2 files changed, 33 insertions, 27 deletions
diff --git a/src/caffe/test/test_caffe_main.cpp b/src/caffe/test/test_caffe_main.cpp new file mode 100644 index 00000000..4674bb4e --- /dev/null +++ b/src/caffe/test/test_caffe_main.cpp @@ -0,0 +1,32 @@ +// Copyright 2013 Yangqing Jia + +// The main caffe test code. Your test cpp code should include this hpp +// to allow a main function to be compiled into the binary. + +#include "test_caffe_main.hpp" + +namespace caffe { + cudaDeviceProp CAFFE_TEST_CUDA_PROP; +} + +using caffe::CAFFE_TEST_CUDA_PROP; + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + ::google::InitGoogleLogging(argv[0]); + // Before starting testing, let's first print out a few cuda defice info. + int device; + cudaGetDeviceCount(&device); + cout << "Cuda number of devices: " << device << endl; + if (argc > 1) { + // Use the given device + device = atoi(argv[1]); + cudaSetDevice(device); + cout << "Setting to use device " << device << endl; + } + cudaGetDevice(&device); + cout << "Current device id: " << device << endl; + cudaGetDeviceProperties(&CAFFE_TEST_CUDA_PROP, device); + // invoke the test. + return RUN_ALL_TESTS(); +} diff --git a/src/caffe/test/test_caffe_main.hpp b/src/caffe/test/test_caffe_main.hpp index 01cb0c81..68374ae6 100644 --- a/src/caffe/test/test_caffe_main.hpp +++ b/src/caffe/test/test_caffe_main.hpp @@ -15,32 +15,6 @@ using std::cout; using std::endl; -namespace caffe { - -cudaDeviceProp CAFFE_TEST_CUDA_PROP; - -} // namespace caffe - -using caffe::CAFFE_TEST_CUDA_PROP; - -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - ::google::InitGoogleLogging(argv[0]); - // Before starting testing, let's first print out a few cuda defice info. - int device; - cudaGetDeviceCount(&device); - cout << "Cuda number of devices: " << device << endl; - if (argc > 1) { - // Use the given device - device = atoi(argv[1]); - cudaSetDevice(device); - cout << "Setting to use device " << device << endl; - } - cudaGetDevice(&device); - cout << "Current device id: " << device << endl; - cudaGetDeviceProperties(&CAFFE_TEST_CUDA_PROP, device); - // invoke the test. - return RUN_ALL_TESTS(); -} +int main(int argc, char** argv); #endif // CAFFE_TEST_TEST_CAFFE_MAIN_HPP_ |