Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 3a09f26

Browse files
committed
Fix addition type for agg_double_*
1 parent da49f54 commit 3a09f26

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

omniscidb/QueryEngine/Compiler/genx.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,25 @@ void agg_sum_float_skip_val_shared(GENERIC_ADDR_SPACE int32_t* agg,
218218
}
219219
}
220220

221+
void agg_sum_double_shared(GENERIC_ADDR_SPACE int64_t* agg, const double val) {
222+
int64_t old = *agg, assumed;
223+
224+
do {
225+
assumed = old;
226+
old = atomic_cas_int_64(
227+
agg, assumed, hdk_double_as_int64_t(val + hdk_int64_t_as_double(assumed)));
228+
} while (assumed != old);
229+
}
230+
221231
void agg_sum_double_skip_val_shared(GENERIC_ADDR_SPACE int64_t* agg,
222232
const double val,
223233
const double skip_val) {
224234
if (hdk_double_as_int64_t(val) != hdk_double_as_int64_t(skip_val)) {
225235
int64_t old = atomic_xchg_int_64(agg, hdk_double_as_int64_t(0.));
226236
agg_sum_double_shared(agg,
227-
old == hdk_double_as_int64_t(skip_val) ? val : (val + old));
237+
old == hdk_double_as_int64_t(skip_val)
238+
? val
239+
: (val + hdk_int64_t_as_double(old)));
228240
}
229241
}
230242

omniscidb/QueryEngine/Compiler/genx.ll

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,24 +128,6 @@ define void @agg_sum_float_shared(i32 addrspace(4)* %agg, float noundef %val) {
128128
ret void
129129
}
130130

131-
define void @agg_sum_double_shared(i64 addrspace(4)* %agg, double noundef %val) {
132-
.entry:
133-
%orig = load atomic i64, i64 addrspace(4)* %agg unordered, align 8
134-
%cst = bitcast i64 %orig to double
135-
br label %.loop
136-
.loop:
137-
%cmp = phi i64 [ %orig, %.entry ], [ %loaded, %.loop ]
138-
%cmp_cst = bitcast i64 %cmp to double
139-
%new_val = fadd double %cmp_cst, %val
140-
%new_val_cst = bitcast double %new_val to i64
141-
%val_success = cmpxchg i64 addrspace(4)* %agg, i64 %cmp, i64 %new_val_cst acq_rel monotonic
142-
%loaded = extractvalue {i64, i1} %val_success, 0
143-
%success = extractvalue {i64, i1} %val_success, 1
144-
br i1 %success, label %.exit, label %.loop
145-
.exit:
146-
ret void
147-
}
148-
149131
define void @atomic_or(i32 addrspace(4)* %addr, i32 noundef %val) {
150132
.entry:
151133
%orig = load atomic i32, i32 addrspace(4)* %addr unordered, align 8

0 commit comments

Comments
 (0)