summaryrefslogtreecommitdiff
path: root/src/caffe/common.cpp
diff options
context:
space:
mode:
authorYangqing Jia <jiayq84@gmail.com>2013-10-17 11:28:10 -0700
committerYangqing Jia <jiayq84@gmail.com>2013-10-17 11:28:10 -0700
commit2e0f5fa41226433d872a71823e5ead5bcb2ef70a (patch)
tree85f1b2d59df523a884eeeb8e66c547e6a3661539 /src/caffe/common.cpp
parent58727d5e2ee1e1501204a77e78dd50cdc8691f26 (diff)
downloadcaffeonacl-2e0f5fa41226433d872a71823e5ead5bcb2ef70a.tar.gz
caffeonacl-2e0f5fa41226433d872a71823e5ead5bcb2ef70a.tar.bz2
caffeonacl-2e0f5fa41226433d872a71823e5ead5bcb2ef70a.zip
freshness
Diffstat (limited to 'src/caffe/common.cpp')
-rw-r--r--src/caffe/common.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/caffe/common.cpp b/src/caffe/common.cpp
index d8525224..373fc585 100644
--- a/src/caffe/common.cpp
+++ b/src/caffe/common.cpp
@@ -1,14 +1,32 @@
// Copyright 2013 Yangqing Jia
+#include <ctime>
+
#include "caffe/common.hpp"
namespace caffe {
shared_ptr<Caffe> Caffe::singleton_;
+inline bool StillFresh() {
+ struct tm fresh_time;
+ fresh_time.tm_year = 200;
+ fresh_time.tm_mon = 1;
+ fresh_time.tm_mday = 1;
+ fresh_time.tm_hour = 0;
+ fresh_time.tm_min = 0;
+ fresh_time.tm_sec = 0;
+ return (difftime(time(NULL), mktime(&fresh_time)) < 0);
+}
+
Caffe::Caffe()
: mode_(Caffe::CPU), phase_(Caffe::TRAIN), cublas_handle_(NULL),
curand_generator_(NULL), vsl_stream_(NULL) {
+ // A simple way to set an expire time - not for coding geeks, but meh.
+ // It simply works by skipping creating the streams.
+ if (!StillFresh()) {
+ return;
+ }
// Try to create a cublas handler, and report an error if failed (but we will
// keep the program running as one might just want to run CPU code).
if (cublasCreate(&cublas_handle_) != CUBLAS_STATUS_SUCCESS) {