OSDN Git Service

modified: utilsrc/src/Admin/Makefile
[eos/others.git] / utiltools / X86MAC64 / cuda / include / fatbinary.h
1 /*
2  *  Copyright 2010 NVIDIA Corporation.  All rights reserved.
3  *
4  *  NOTICE TO USER: The source code, and related code and software
5  *  ("Code"), is copyrighted under U.S. and international laws.
6  *
7  *  NVIDIA Corporation owns the copyright and any patents issued or
8  *  pending for the Code.
9  *
10  *  NVIDIA CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY
11  *  OF THIS CODE FOR ANY PURPOSE.  IT IS PROVIDED "AS-IS" WITHOUT EXPRESS
12  *  OR IMPLIED WARRANTY OF ANY KIND.  NVIDIA CORPORATION DISCLAIMS ALL
13  *  WARRANTIES WITH REGARD TO THE CODE, INCLUDING NON-INFRINGEMENT, AND
14  *  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15  *  PURPOSE.  IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY
16  *  DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
17  *  WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATED TO THE USE OR
18  *  PERFORMANCE OF THE CODE, INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT,
19  *  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
20  *  NEGLIGENCE OR OTHER TORTIOUS ACTION, AND WHETHER OR NOT THE
21  *  POSSIBILITY OF SUCH DAMAGES WERE KNOWN OR MADE KNOWN TO NVIDIA
22  *  CORPORATION.
23  *
24  */
25
26 #ifndef fatbinary_INCLUDED
27 #define fatbinary_INCLUDED
28
29 /* 
30  * This is the fat binary header structure. 
31  * Because all layout information is contained in all the structures, 
32  * it is both forward and backward compatible. 
33  * A new driver can interpret an old binary 
34  * as it will not address fields that are present in the current version. 
35  * An old driver can, for minor version differences, 
36  * still interpret a new binary, 
37  * as the new features in the binary will be ignored by the driver.
38  *
39  * This is the top level type for the binary format. 
40  * It points to a fatBinaryHeader structure. 
41  * It is followed by a number of code binaries.
42  * The structures must be 8-byte aligned, 
43  * and are the same on both 32bit and 64bit platforms.
44  *
45  * The details of the format for the binaries that follow the header
46  * are in a separate internal header.
47  */
48
49 typedef struct fatBinaryHeader *computeFatBinaryFormat_t;
50
51 /* ensure 8-byte alignment */
52 #if defined(__GNUC__)
53 #define __align__(n) __attribute__((aligned(n)))
54 #elif defined(_WIN32)
55 #define __align__(n) __declspec(align(n))
56 #else
57 #error !! UNSUPPORTED COMPILER !!
58 #endif
59
60 /* Magic numbers */
61 #define FATBIN_MAGIC 0xBA55ED50
62 #define OLD_STYLE_FATBIN_MAGIC 0x1EE55A01
63
64 #define FATBIN_VERSION 0x0001
65
66 /*
67  * This is the fat binary header structure. 
68  * The 'magic' field holds the magic number. 
69  * A magic of OLD_STYLE_FATBIN_MAGIC indicates an old style fat binary. 
70  * Because old style binaries are in little endian, we can just read 
71  * the magic in a 32 bit container for both 32 and 64 bit platforms. 
72  * The 'version' fields holds the fatbin version.
73  * It should be the goal to never bump this version. 
74  * The headerSize holds the size of the header (must be multiple of 8).
75  * The 'fatSize' fields holds the size of the entire fat binary, 
76  * excluding this header. It must be a multiple of 8.
77  */
78 struct __align__(8) fatBinaryHeader
79 {
80   unsigned int           magic;
81   unsigned short         version;
82   unsigned short         headerSize;
83   unsigned long long int fatSize;
84 };
85
86 /* Code kinds supported by the driver */
87 typedef enum {
88   FATBIN_KIND_PTX      = 0x0001,
89   FATBIN_KIND_ELF      = 0x0002,
90   FATBIN_KIND_OLDCUBIN = 0x0004,
91 } fatBinaryCodeKind;
92
93 /* Flags */
94 #define FATBIN_FLAG_64BIT     0x0000000000000001LL
95 #define FATBIN_FLAG_DEBUG     0x0000000000000002LL
96 #define FATBIN_FLAG_CUDA      0x0000000000000004LL
97 #define FATBIN_FLAG_OPENCL    0x0000000000000008LL
98 #define FATBIN_FLAG_LINUX     0x0000000000000010LL
99 #define FATBIN_FLAG_MAC       0x0000000000000020LL
100 #define FATBIN_FLAG_WINDOWS   0x0000000000000040LL
101 #define FATBIN_FLAG_HOST_MASK 0x00000000000000f0LL
102 #define FATBIN_FLAG_OPT_MASK  0x0000000000000f00LL /* optimization level */
103 #define FATBIN_FLAG_COMPRESS  0x0000000000001000LL
104 /* note that should use new flag if ever change compression algorithm */
105
106 #define SET_FATBIN_FLAG(f,v) ((f) |= (v))
107 #define GET_FATBIN_FLAG(f,v) ((f) & (v))
108
109 #endif /* fatbinary_INCLUDED */