File size: 2,029 Bytes
f8c5b0d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#pragma once

// OpenCL Utils includes
#include "OpenCLUtils_Export.h"

// OpenCL includes
#include <CL/cl.h>

// STL includes
#include <time.h>

UTILS_EXPORT
cl_context cl_util_get_context(const cl_uint plat_id, const cl_uint dev_id,
                               const cl_device_type type, cl_int* const error);
UTILS_EXPORT
cl_device_id cl_util_get_device(const cl_uint plat_id, const cl_uint dev_id,
                                const cl_device_type type, cl_int* const error);

UTILS_EXPORT
cl_int cl_util_print_device_info(const cl_device_id device);

UTILS_EXPORT
char* cl_util_get_device_info(const cl_device_id device,
                              const cl_device_info info, cl_int* const error);
UTILS_EXPORT
char* cl_util_get_platform_info(const cl_platform_id platform,
                                const cl_platform_info info,
                                cl_int* const error);

// build program and show log if build is not successful
UTILS_EXPORT
cl_int cl_util_build_program(const cl_program pr, const cl_device_id dev,
                             const char* const opt);

#define GET_CURRENT_TIMER(time)                                                \
    struct timespec time;                                                      \
    timespec_get(&time, TIME_UTC);                                             \
    {                                                                          \
    }

#define TIMER_DIFFERENCE(dt, time1, time2)                                     \
    {                                                                          \
        dt = (time2.tv_sec - time1.tv_sec) * 1000000000                        \
            + (time2.tv_nsec - time1.tv_nsec);                                 \
    }

#define START_TIMER GET_CURRENT_TIMER(start_timer1)
#define STOP_TIMER(dt)                                                         \
    GET_CURRENT_TIMER(stop_timer2)                                             \
    TIMER_DIFFERENCE(dt, start_timer1, stop_timer2)