Lift
Library of parallel computing primitives for GPUs and multi-core CPUs
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
src
test
entrypoint.cu
Go to the documentation of this file.
1
/*
2
* Lift
3
*
4
* Copyright (c) 2014-2015, NVIDIA CORPORATION
5
* Copyright (c) 2015-2016, Nuno Subtil <subtil@gmail.com>
6
* Copyright (c) 2015-2016, Roche Molecular Systems Inc.
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions are met:
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* * Redistributions in binary form must reproduce the above copyright
14
* notice, this list of conditions and the following disclaimer in the
15
* documentation and/or other materials provided with the distribution.
16
* * Neither the name of the copyright holders nor the names of its
17
* contributors may be used to endorse or promote products derived from
18
* this software without specific prior written permission.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
24
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
*/
31
32
#include <
lift/tests/harness.h
>
33
34
#include <
lift/sys/compute_device.h
>
35
#include <
lift/sys/host/compute_device_host.h
>
36
#include <
lift/sys/cuda/compute_device_cuda.h
>
37
38
namespace
lift {
39
40
// the current test object pointer
41
thread_local
test
*
current_test
=
nullptr
;
42
// master list of tests to run
43
// will be populated by external code
44
std::vector<test *>
test_list
= { };
45
46
}
47
48
using namespace
lift;
49
50
// debugging aid: set a breakpoint here to catch check failures
51
void
debug_check_failure
(
void
)
52
{
53
}
54
55
int
main
(
int
argc,
char
**argv)
56
{
57
compute_device_host
cpu;
58
bool
has_cuda;
59
60
printf(
"Lift test harness\n"
);
61
printf(
"CPU: %s\n"
, cpu.
get_name
());
62
63
std::vector<cuda_device_config> gpu_list;
64
std::string err;
65
66
cuda_device_config::enumerate_gpus
(gpu_list, err);
67
if
(gpu_list.size() == 0)
68
{
69
has_cuda =
false
;
70
}
else
{
71
has_cuda =
true
;
72
73
if
(gpu_list.size() == 1)
74
{
75
printf(
"GPU: %s\n"
, gpu_list[0].device_name);
76
}
else
{
77
printf(
"GPU list:\n"
);
78
for
(
size_t
i = 0; i < gpu_list.size(); i++)
79
{
80
printf(
"%lu: %s\n"
, i, gpu_list[i].device_name);
81
}
82
}
83
}
84
printf(
"\n"
);
85
86
generate_test_list
();
87
bool
success =
true
;
88
89
size_t
tests_run = 0;
90
size_t
tests_passed = 0;
91
size_t
tests_failed = 0;
92
93
printf(
"running tests:\n"
);
94
for
(
size_t
i = 0; i <
test_list
.size(); i++)
95
{
96
if
(
test_list
[i]->need_cuda && !has_cuda)
97
{
98
continue
;
99
}
100
101
printf(
" %s... "
,
test_list
[i]->name.c_str());
102
fflush(stdout);
103
104
current_test
=
test_list
[i];
105
106
test_list
[i]->setup();
107
108
test_list
[i]->test_passed =
true
;
109
test_list
[i]->run();
110
111
tests_run++;
112
113
test_list
[i]->teardown();
114
115
if
(!
test_list
[i]->test_passed)
116
{
117
printf(
"\n FAILED!\n\n"
);
118
success =
false
;
119
tests_failed++;
120
}
else
{
121
printf(
"passed\n"
);
122
tests_passed++;
123
}
124
125
fflush(stdout);
126
}
127
128
printf(
"\n%lu out of %lu tests run, %lu passed / %lu failed\n"
,
129
tests_run,
test_list
.size(),
130
tests_passed, tests_failed);
131
132
return
(success ? 0 : 1);
133
}
lift::compute_device_host::get_name
virtual const char * get_name(void) override
Definition:
compute_device_host.h:104
compute_device_host.h
lift::compute_device_host
Definition:
compute_device_host.h:81
harness.h
debug_check_failure
void debug_check_failure(void)
Definition:
entrypoint.cu:51
lift::test
The test object interface.
Definition:
harness.h:42
compute_device_cuda.h
lift::current_test
thread_local test * current_test
Definition:
entrypoint.cu:41
main
int main(int argc, char **argv)
Definition:
entrypoint.cu:55
lift::cuda_device_config::enumerate_gpus
static bool enumerate_gpus(std::vector< cuda_device_config > &devices, std::string &error, const cuda_device_config &requirements=cuda_device_config())
Definition:
compute_device_cuda.cu:59
lift::test_list
std::vector< test * > test_list
Definition:
entrypoint.cu:44
generate_test_list
void generate_test_list(void)
compute_device.h
Generated by
1.8.6