Debian Codegraph @

Samples/2_Concepts_and_Techniques/dct8x8/Common.h

raw
1 /* Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
2 *
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions
5 * are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution.
11 * * Neither the name of NVIDIA CORPORATION nor the names of its
12 * contributors may be used to endorse or promote products derived
13 * from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 /**
29 **************************************************************************
30 * \file Common.h
31 * \brief Common includes header.
32 *
33 * This file contains includes of all libraries used by the project.
34 */
35
36 #pragma once
37
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <math.h>
41
42 #include <cuda_runtime.h>
43 #include <helper_cuda.h> // helper functions for CUDA timing and initialization
44 #include <helper_functions.h> // helper functions for timing, string parsing
45
46 /**
47 * The dimension of pixels block
48 */
49 #define BLOCK_SIZE 8
50
51 /**
52 * Square of dimension of pixels block
53 */
54 #define BLOCK_SIZE2 64
55
56 /**
57 * log_2{BLOCK_SIZE), used for quick multiplication or division by the
58 * pixels block dimension via shifting
59 */
60 #define BLOCK_SIZE_LOG2 3
61
62 /**
63 * log_2{BLOCK_SIZE*BLOCK_SIZE), used for quick multiplication or division by
64 * the
65 * square of pixels block via shifting
66 */
67 #define BLOCK_SIZE2_LOG2 6
68
69 /**
70 * This macro states that __mul24 operation is performed faster that traditional
71 * multiplication for two integers on CUDA. Please undefine if it appears to be
72 * wrong on your system
73 */
74 #define __MUL24_FASTER_THAN_ASTERIX
75
76 /**
77 * Wrapper to the fastest integer multiplication function on CUDA
78 */
79 #ifdef __MUL24_FASTER_THAN_ASTERIX
80 #define FMUL(x, y) (__mul24(x, y))
81 #else
82 #define FMUL(x, y) ((x) * (y))
83 #endif
84
85 /**
86 * This macro allows using aligned memory management
87 */
88 //#define __ALLOW_ALIGNED_MEMORY_MANAGEMENT