1 //////////////////////////////////////////////////////////////////////////////// 2 // 3 // The University of Illinois/NCSA 4 // Open Source License (NCSA) 5 // 6 // Copyright (c) 2014-2015, Advanced Micro Devices, Inc. All rights reserved. 7 // 8 // Developed by: 9 // 10 // AMD Research and AMD HSA Software Development 11 // 12 // Advanced Micro Devices, Inc. 13 // 14 // www.amd.com 15 // 16 // Permission is hereby granted, free of charge, to any person obtaining a copy 17 // of this software and associated documentation files (the "Software"), to 18 // deal with the Software without restriction, including without limitation 19 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 20 // and/or sell copies of the Software, and to permit persons to whom the 21 // Software is furnished to do so, subject to the following conditions: 22 // 23 // - Redistributions of source code must retain the above copyright notice, 24 // this list of conditions and the following disclaimers. 25 // - Redistributions in binary form must reproduce the above copyright 26 // notice, this list of conditions and the following disclaimers in 27 // the documentation and/or other materials provided with the distribution. 28 // - Neither the names of Advanced Micro Devices, Inc, 29 // nor the names of its contributors may be used to endorse or promote 30 // products derived from this Software without specific prior written 31 // permission. 32 // 33 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 34 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 35 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 36 // THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 37 // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 38 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 39 // DEALINGS WITH THE SOFTWARE. 40 // 41 //////////////////////////////////////////////////////////////////////////////// 42 43 // The following set of header files provides definitions for AMD GPU 44 // Architecture: 45 // - amd_hsa_common.h 46 // - amd_hsa_elf.h 47 // - amd_hsa_kernel_code.h 48 // - amd_hsa_queue.h 49 // - amd_hsa_signal.h 50 // 51 // Refer to "HSA Application Binary Interface: AMD GPU Architecture" for more 52 // information. 53 54 #ifndef AMD_HSA_COMMON_H 55 #define AMD_HSA_COMMON_H 56 57 #include <stddef.h> 58 #include <stdint.h> 59 60 // Descriptive version of the HSA Application Binary Interface. 61 #define AMD_HSA_ABI_VERSION "AMD GPU Architecture v0.35 (June 25, 2015)" 62 63 // Alignment attribute that specifies a minimum alignment (in bytes) for 64 // variables of the specified type. 65 #if defined(__GNUC__) 66 # define __ALIGNED__(x) __attribute__((aligned(x))) 67 #elif defined(_MSC_VER) 68 # define __ALIGNED__(x) __declspec(align(x)) 69 #elif defined(RC_INVOKED) 70 # define __ALIGNED__(x) 71 #else 72 # error 73 #endif 74 75 // Creates enumeration entries for packed types. Enumeration entries include 76 // bit shift amount, bit width, and bit mask. 77 #define AMD_HSA_BITS_CREATE_ENUM_ENTRIES(name, shift, width) \ 78 name##_SHIFT = (shift), \ 79 name##_WIDTH = (width), \ 80 name = (((1 << (width)) - 1) << (shift)) \ 81 82 // Gets bits for specified mask from specified src packed instance. 83 #define AMD_HSA_BITS_GET(src, mask) \ 84 ((src & mask) >> mask ## _SHIFT) \ 85 86 // Sets val bits for specified mask in specified dst packed instance. 87 #define AMD_HSA_BITS_SET(dst, mask, val) \ 88 dst &= (~(1 << mask##_SHIFT) & ~mask); \ 89 dst |= (((val) << mask##_SHIFT) & mask) \ 90 91 #endif // AMD_HSA_COMMON_H 92