2 * Copyright (c) 2011-2015 Advanced Micro Devices, Inc.
5 * For use for simulation and test purposes only
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
17 * 3. Neither the name of the copyright holder nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
33 * Author: Brad Beckmann, Marc Orr
36 #ifndef __Q_STRUCT_HH__
37 #define __Q_STRUCT_HH__
42 // Maximum number of arguments
43 static const int KER_NUM_ARGS = 32;
44 // Kernel argument buffer size
45 static const int KER_ARGS_LENGTH = 512;
50 // Be very careful of alignment in this structure. The structure
51 // must compile to the same layout in both 32-bit and 64-bit mode.
54 // Base pointer for array of instruction pointers
56 // Grid Size (3 dimensions)
58 // Workgroup Size (3 dimensions)
63 uint64_t privMemStart;
64 uint32_t privMemPerItem;
65 uint32_t privMemTotal;
66 uint64_t spillMemStart;
67 uint32_t spillMemPerItem;
68 uint32_t spillMemTotal;
71 // Size (in bytes) of LDS
73 // Virtual Memory Id (unused right now)
76 // Pointer to dependency chain (unused now)
80 uint64_t addrToNotify;
81 // pointer to uint32_t
84 // variables to pass arguments when running in standalone mode,
85 // will be removed when run.py and sh.cpp have been updated to
86 // use args and offset arrays
92 // variables to pass arguments when running in cpu+gpu mode
93 uint8_t args[KER_ARGS_LENGTH];
94 uint16_t offsets[KER_NUM_ARGS];
98 // State that needs to be passed between the simulation and simulated app, a
99 // pointer to this struct can be passed through the depends field in the
100 // HsaQueueEntry struct
103 // cl_event* has original HsaQueueEntry for init
107 // Total number of HSA queues
108 static const int HSAQ_NQUEUES = 8;
110 // These values will eventually live in memory mapped registers
111 // and be settable by the kernel mode driver.
113 // Number of entries in each HSA queue
114 static const int HSAQ_SIZE = 64;
115 // Address of first HSA queue index
116 static const int HSAQ_INDX_BASE = 0x10000ll;
117 // Address of first HSA queue
118 static const int HSAQ_BASE = 0x11000ll;
119 // Suggested start of HSA code
120 static const int HSA_CODE_BASE = 0x18000ll;
122 // These are shortcuts for deriving the address of a specific
123 // HSA queue or queue index
124 #define HSAQ(n) (HSAQ_BASE + HSAQ_SIZE * sizeof(struct fsaQueue) * n)
125 #define HSAQE(n,i) (HSAQ_BASE + (HSAQ_SIZE * n + i) * sizeof(struct fsaQueue))
126 #define HSAQ_RI(n) (HSAQ_INDX_BASE + sizeof(int) * (n * 3 + 0))
127 #define HSAQ_WI(n) (HSAQ_INDX_BASE + sizeof(int) * (n * 3 + 1))
128 #define HSAQ_CI(n) (HSAQ_INDX_BASE + sizeof(int) * (n * 3 + 2))
131 * Example code for writing to a queue
134 * ToQueue(int n,struct fsaQueue *val)
136 * int wi = *(int*)HSAQ_WI(n);
137 * int ri = *(int*)HSAQ_RI(n);
138 * int ci = *(int*)HSAQ_CI(n);
140 * if (ci - ri < HSAQ_SIZE) {
141 * (*(int*)HSAQ_CI(n))++;
142 * *(HsaQueueEntry*)(HSAQE(n, (wi % HSAQ_SIZE))) = *val;
143 * (*(int*)HSAQ_WI(n))++;
148 #endif // __Q_STRUCT_HH__