|
54 | 54 | //
|
55 | 55 | #define compareFunctionBody(typeName, direction, load, dataPtr, idx1p, idx2p) \
|
56 | 56 | { \
|
57 |
| - uint64_t idx1 = *((uint64_t *)idx1p); \ |
58 |
| - uint64_t idx2 = *((uint64_t *)idx2p); \ |
59 |
| - typeName *data = (typeName *)dataPtr; \ |
| 57 | + uint64_t idx1 = *((uint64_t *)(idx1p)); \ |
| 58 | + uint64_t idx2 = *((uint64_t *)(idx2p)); \ |
| 59 | + typeName *data = (typeName *)(dataPtr); \ |
60 | 60 | load(typeName, v1, data[idx1]); \
|
61 | 61 | load(typeName, v2, data[idx2]); \
|
62 | 62 | return (direction(v1, v2) || (v1 == v2 && idx1 < idx2)) ? -1 : 1; \
|
@@ -89,15 +89,15 @@ typedef int(
|
89 | 89 | #pragma GCC diagnostic ignored "-Wcast-qual"
|
90 | 90 | #endif
|
91 | 91 |
|
92 |
| -#define Load(typeName, to, from) typeName to = from |
| 92 | +#define Load(typeName, to, from) typeName (to) = (from) |
93 | 93 |
|
94 | 94 | // Convert f16 elements to f32 for comparison because we don't have logic to
|
95 | 95 | // compare f16 elements directly on all platforms.
|
96 | 96 | // TODO: Use Convert(_Float16, to, from) on supported platforms.
|
97 | 97 | // Or consider converting the whole tensor to f32, sort as f32, and then
|
98 | 98 | // convert the sorted tensor back to f16. That may be faster than
|
99 | 99 | // converting elements for each comparison during sorting.
|
100 |
| -#define LoadF16AsF32(typeName, to, from) float to = om_f16_to_f32(from) |
| 100 | +#define LoadF16AsF32(typeName, to, from) float (to) = om_f16_to_f32(from) |
101 | 101 |
|
102 | 102 | // declare ascending functions
|
103 | 103 | #define Ascending(lhs, rhs) ((lhs) < (rhs))
|
@@ -169,35 +169,35 @@ typedef struct indexStack {
|
169 | 169 |
|
170 | 170 | #define STACK_INIT(stack, stackSize) \
|
171 | 171 | do { \
|
172 |
| - assert(stackSize > 0); \ |
173 |
| - stack.stackData = (uint64_t *)alloca(stackSize * sizeof(uint64_t)); \ |
174 |
| - assert(stack.stackData != NULL); \ |
175 |
| - stack.stackSize = stackSize; \ |
176 |
| - stack.stackTop = 0; \ |
| 172 | + assert((stackSize) > 0); \ |
| 173 | + (stack).stackData = (uint64_t *)alloca((stackSize) * sizeof(uint64_t)); \ |
| 174 | + assert((stack).stackData != NULL); \ |
| 175 | + (stack).stackSize = (stackSize); \ |
| 176 | + (stack).stackTop = 0; \ |
177 | 177 | } while (0)
|
178 |
| -#define STACK_ISEMPTY(stack) (stack.stackTop == 0) |
| 178 | +#define STACK_ISEMPTY(stack) ((stack).stackTop == 0) |
179 | 179 | #define STACK_PUSH(stack, begin, end) \
|
180 | 180 | do { \
|
181 |
| - assert(stack.stackTop <= stack.stackSize - 2); \ |
182 |
| - stack.stackData[(stack.stackTop)++] = begin; \ |
183 |
| - stack.stackData[(stack.stackTop)++] = end; \ |
| 181 | + assert((stack).stackTop <= (stack).stackSize - 2); \ |
| 182 | + (stack).stackData[((stack).stackTop)++] = (begin); \ |
| 183 | + (stack).stackData[((stack).stackTop)++] = (end); \ |
184 | 184 | } while (0)
|
185 | 185 | #define STACK_POP(stack, begin, end) \
|
186 | 186 | do { \
|
187 |
| - assert(stack.stackTop >= 2); \ |
188 |
| - end = stack.stackData[--(stack.stackTop)]; \ |
189 |
| - begin = stack.stackData[--(stack.stackTop)]; \ |
| 187 | + assert((stack).stackTop >= 2); \ |
| 188 | + (end) = (stack).stackData[--((stack).stackTop)]; \ |
| 189 | + (begin) = (stack).stackData[--((stack).stackTop)]; \ |
190 | 190 | } while (0)
|
191 | 191 | #define STACK_PRINT(stack) \
|
192 | 192 | do { \
|
193 |
| - assert(stack.stackTop >= 0); \ |
| 193 | + assert((stack).stackTop >= 0); \ |
194 | 194 | fprintf(stderr, "Stack: ["); \
|
195 |
| - for (int64_t i = 0; (i + 1) < stack.stackTop; i += 2) { \ |
| 195 | + for (int64_t i = 0; (i + 1) < (stack).stackTop; i += 2) { \ |
196 | 196 | fprintf( \
|
197 |
| - stderr, "<%ld:%ld>, ", stack.stackData[i], stack.stackData[i + 1]); \ |
| 197 | + stderr, "<%ld:%ld>, ", (stack).stackData[i], (stack).stackData[i + 1]);\ |
198 | 198 | } \
|
199 | 199 | fprintf( \
|
200 |
| - stderr, "] (Top=%ld,Size=%ld)\n", stack.stackTop, stack.stackSize); \ |
| 200 | + stderr, "] (Top=%ld,Size=%ld)\n", (stack).stackTop, (stack).stackSize);\ |
201 | 201 | fflush(stderr); \
|
202 | 202 | } while (0)
|
203 | 203 |
|
|
0 commit comments