1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2012-2017 VideoStitch SAS
// Copyright (c) 2018 stitchEm
#include "libvideostitch/context.hpp"
#include "cuda/error.hpp"
#include "libvideostitch/algorithm.hpp"
#include "libvideostitch/allocator.hpp"
#include <cuda_runtime.h>
#ifndef TEST_KERNEL_PROGRESS_BAR
#define TEST_KERNEL_PROGRESS_BAR 0
#endif
#if TEST_KERNEL_PROGRESS_BAR
#include <thread>
#include <chrono>
#endif
namespace VideoStitch {
namespace GPU {
namespace Context {
Status compileAllKernels(Util::Algorithm::ProgressReporter* /*pReporter*/) {
// TODO trigger optimization for target architecture, if binary not available?
return Status::OK();
}
Status compileAllKernelsOnSelectedDevice(int, const bool, Util::Algorithm::ProgressReporter*) {
#if TEST_KERNEL_PROGRESS_BAR
FAIL_CONDITION(!pReporter->notify("Compiling kernels", 0.0), VideoStitch::Origin::GPU,
VideoStitch::ErrType::RuntimeError, "Canceled");
std::this_thread::sleep_for(std::chrono::seconds(1));
FAIL_CONDITION(!pReporter->notify("Compiling kernels", 0.3), VideoStitch::Origin::GPU,
VideoStitch::ErrType::RuntimeError, "Canceled");
std::this_thread::sleep_for(std::chrono::seconds(1));
FAIL_CONDITION(!pReporter->notify("Compiling kernels", 0.5), VideoStitch::Origin::GPU,
VideoStitch::ErrType::RuntimeError, "Canceled");
std::this_thread::sleep_for(std::chrono::seconds(1));
FAIL_CONDITION(!pReporter->notify("Compiling kernels", 0.8), VideoStitch::Origin::GPU,
VideoStitch::ErrType::RuntimeError, "Canceled");
std::this_thread::sleep_for(std::chrono::seconds(1));
pReporter->notify("Compiling kernels", 1.0);
#endif
// return OK for cuda
return Status::OK();
}
Status destroy() { return CUDA_ERROR(cudaDeviceReset()); }
Status setDefaultBackendDeviceAndCheck(const int vsDeviceID) {
FAIL_RETURN(setDefaultBackendDeviceVS(vsDeviceID));
return Core::OpenGLAllocator::createSourceSurface(1, 1).status();
}
} // namespace Context
} // namespace GPU
} // namespace VideoStitch