Changeset: e555d452c75d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e555d452c75d
Added Files:
monetdb5/modules/mosaic/mosaic_delta_templates.h
monetdb5/modules/mosaic/mosaic_dict256_templates.h
monetdb5/modules/mosaic/mosaic_dict_templates.h
monetdb5/modules/mosaic/mosaic_dictionary_templates.h
monetdb5/modules/mosaic/mosaic_frame_templates.h
monetdb5/modules/mosaic/mosaic_linear_templates.h
monetdb5/modules/mosaic/mosaic_prefix_templates.h
monetdb5/modules/mosaic/mosaic_raw_templates.h
monetdb5/modules/mosaic/mosaic_runlength_templates.h
Modified Files:
monetdb5/modules/mosaic/Makefile.ag
monetdb5/modules/mosaic/mosaic_dict.c
monetdb5/modules/mosaic/mosaic_frame.c
monetdb5/modules/mosaic/mosaic_linear.c
monetdb5/modules/mosaic/mosaic_prefix.c
monetdb5/modules/mosaic/mosaic_raw.c
monetdb5/modules/mosaic/mosaic_select_template.h
monetdb5/modules/mosaic/mosaic_select_template2.h
Branch: mosaic
Log Message:
Transform scan_select macro's into template functions.
diffs (truncated from 522 to 300 lines):
diff --git a/monetdb5/modules/mosaic/Makefile.ag
b/monetdb5/modules/mosaic/Makefile.ag
--- a/monetdb5/modules/mosaic/Makefile.ag
+++ b/monetdb5/modules/mosaic/Makefile.ag
@@ -25,15 +25,15 @@ lib_mosaic = {
mosaic_select_template.h mosaic_select_template2.h \
mosaic_projection_template.h \
mosaic_join.h \
- mosaic_raw.c mosaic_raw.h mosaic_raw_template.h \
- mosaic_runlength.c mosaic_runlength.h
mosaic_runlength_template.h \
- mosaic_dict.c mosaic_dict.h \
- mosaic_dict256.c mosaic_dict256.h \
- mosaic_dictionary.h mosaic_dictionary_impl.h
mosaic_dictionary_prepare_context_impl.h \
- mosaic_delta.c mosaic_delta.h mosaic_delta_template.h \
- mosaic_linear.c mosaic_linear.h mosaic_linear_template.h \
- mosaic_frame.c mosaic_frame.h mosaic_frame_template.h \
- mosaic_prefix.c mosaic_prefix.h mosaic_prefix_template.h \
+ mosaic_raw.c mosaic_raw.h mosaic_raw_template.h
mosaic_raw_templates.h \
+ mosaic_runlength.c mosaic_runlength.h
mosaic_runlength_template.h mosaic_runlength_templates.h \
+ mosaic_dict.c mosaic_dict.h mosaic_dict_templates.h \
+ mosaic_dict256.c mosaic_dict256.h mosaic_dict256_templates.h \
+ mosaic_dictionary.h mosaic_dictionary_impl.h
mosaic_dictionary_prepare_context_impl.h mosaic_dictionary_templates.h \
+ mosaic_delta.c mosaic_delta.h mosaic_delta_template.h
mosaic_delta_templates.h \
+ mosaic_linear.c mosaic_linear.h mosaic_linear_template.h
mosaic_linear_templates.h \
+ mosaic_frame.c mosaic_frame.h mosaic_frame_template.h
mosaic_frame_templates.h \
+ mosaic_prefix.c mosaic_prefix.h mosaic_prefix_template.h
mosaic_prefix_templates.h \
mosaic_private.h
}
diff --git a/monetdb5/modules/mosaic/mosaic_delta_templates.h
b/monetdb5/modules/mosaic/mosaic_delta_templates.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mosaic/mosaic_delta_templates.h
@@ -0,0 +1,32 @@
+static inline void CONCAT6(scan_loop_delta_, TPE, _, CAND_ITER, _, TEST)
+(const bool has_nil, const bool anti, MOStask* task, BUN first, BUN last, TPE
tl, TPE th, bool li, bool hi)
+{
+ (void) has_nil;
+ (void) anti;
+ (void) task;
+ (void) tl;
+ (void) th;
+ (void) li;
+ (void) hi;
+
+ oid* o = task->lb;
+ MOSBlockHeaderTpe(delta, TPE)* parameters = (MOSBlockHeaderTpe(delta,
TPE)*) task->blk;
+ BitVector base = (BitVector) MOScodevectorDelta(task, TPE);
+ DeltaTpe(TPE) acc = (DeltaTpe(TPE)) parameters->init; /*previous value*/
+ const bte bits = parameters->bits;
+ DeltaTpe(TPE) sign_mask = (DeltaTpe(TPE)) ((IPTpe(TPE)) 1) << (bits -
1);
+ TPE v = (TPE) acc;
+ (void) v;
+ BUN j = 0;
+ for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CAND_ITER(task->ci)) {
+ BUN i = (BUN) (c - first);
+ for (;j <= i; j++) {
+ TPE delta = getBitVector(base, j, bits);
+ v = ACCUMULATE(acc, delta, sign_mask, TPE);
+ }
+ /*TODO: change from control to data dependency.*/
+ if (CONCAT2(_, TEST))
+ *o++ = c;
+ }
+ task->lb = o;
+}
diff --git a/monetdb5/modules/mosaic/mosaic_dict.c
b/monetdb5/modules/mosaic/mosaic_dict.c
--- a/monetdb5/modules/mosaic/mosaic_dict.c
+++ b/monetdb5/modules/mosaic/mosaic_dict.c
@@ -114,9 +114,6 @@ MOSlayout_dict(MOStask* task, BAT *btech
#endif
#undef NAME
-#define scan_loop_dict(TPE, CI_NEXT, TEST) \
- scan_loop_dictionary(dict, TPE, CI_NEXT, TEST)
-
#define NAME dict
#define TPE bte
#include "mosaic_select_template.h"
diff --git a/monetdb5/modules/mosaic/mosaic_dict256_templates.h
b/monetdb5/modules/mosaic/mosaic_dict256_templates.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mosaic/mosaic_dict256_templates.h
@@ -0,0 +1,1 @@
+#include "mosaic_dictionary_templates.h"
diff --git a/monetdb5/modules/mosaic/mosaic_dict_templates.h
b/monetdb5/modules/mosaic/mosaic_dict_templates.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mosaic/mosaic_dict_templates.h
@@ -0,0 +1,1 @@
+#include "mosaic_dictionary_templates.h"
diff --git a/monetdb5/modules/mosaic/mosaic_dictionary_templates.h
b/monetdb5/modules/mosaic/mosaic_dictionary_templates.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mosaic/mosaic_dictionary_templates.h
@@ -0,0 +1,26 @@
+static inline void CONCAT2(CONCAT4(scan_loop_, NAME, _, TPE), CONCAT4(_,
CAND_ITER, _, TEST))
+(const bool has_nil, const bool anti, MOStask* task, BUN first, BUN last, TPE
tl, TPE th, bool li, bool hi)
+{
+ (void) has_nil;
+ (void) anti;
+ (void) task;
+ (void) tl;
+ (void) th;
+ (void) li;
+ (void) hi;
+
+ oid* o = task->lb;
+ TPE* dict = GET_FINAL_DICT(task, NAME, TPE);
+ BitVector base = MOScodevectorDict(task, NAME, TPE);
+ bte bits = GET_FINAL_BITS(task, NAME);
+ for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CAND_ITER(task->ci)) {
+ BUN i = (BUN) (c - first);
+ BitVectorChunk j = getBitVector(base,i,bits);
+ TPE v = dict[j];
+ (void) v;
+ /*TODO: change from control to data dependency.*/
+ if (CONCAT2(_, TEST))
+ *o++ = c;
+ }
+ task->lb = o;
+}
diff --git a/monetdb5/modules/mosaic/mosaic_frame.c
b/monetdb5/modules/mosaic/mosaic_frame.c
--- a/monetdb5/modules/mosaic/mosaic_frame.c
+++ b/monetdb5/modules/mosaic/mosaic_frame.c
@@ -80,20 +80,6 @@ MOSlayout_frame(MOStask* task, BAT *btec
#undef TPE
#endif
-#define scan_loop_frame(TPE, CANDITER_NEXT, TEST) {\
- MOSBlockHeaderTpe(frame, TPE)* parameters = (MOSBlockHeaderTpe(frame,
TPE)*) task->blk;\
- TPE min = parameters->min;\
- BitVector base = (BitVector) MOScodevectorFrame(task, TPE);\
- for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CANDITER_NEXT(task->ci)) {\
- BUN i = (BUN) (c - first);\
- TPE delta = getBitVector(base, i, parameters->bits);\
- v = ADD_DELTA(TPE, min, delta);\
- /*TODO: change from control to data dependency.*/\
- if (TEST)\
- *o++ = c;\
- }\
-}
-
#define NAME frame
#define TPE bte
#include "mosaic_select_template.h"
diff --git a/monetdb5/modules/mosaic/mosaic_frame_templates.h
b/monetdb5/modules/mosaic/mosaic_frame_templates.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mosaic/mosaic_frame_templates.h
@@ -0,0 +1,26 @@
+static inline void CONCAT6(scan_loop_frame_, TPE, _, CAND_ITER, _, TEST)
+(const bool has_nil, const bool anti, MOStask* task, BUN first, BUN last, TPE
tl, TPE th, bool li, bool hi)
+{
+ (void) has_nil;
+ (void) anti;
+ (void) task;
+ (void) tl;
+ (void) th;
+ (void) li;
+ (void) hi;
+
+ oid* o = task->lb;
+ MOSBlockHeaderTpe(frame, TPE)* parameters = (MOSBlockHeaderTpe(frame,
TPE)*) task->blk;
+ TPE min = parameters->min;
+ BitVector base = (BitVector) MOScodevectorFrame(task, TPE);
+ for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CAND_ITER(task->ci)) {
+ BUN i = (BUN) (c - first);
+ TPE delta = getBitVector(base, i, parameters->bits);
+ TPE v = ADD_DELTA(TPE, min, delta);
+ (void) v;
+ /*TODO: change from control to data dependency.*/
+ if (CONCAT2(_, TEST))
+ *o++ = c;
+ }
+ task->lb = o;
+}
diff --git a/monetdb5/modules/mosaic/mosaic_linear.c
b/monetdb5/modules/mosaic/mosaic_linear.c
--- a/monetdb5/modules/mosaic/mosaic_linear.c
+++ b/monetdb5/modules/mosaic/mosaic_linear.c
@@ -79,18 +79,6 @@ MOSlayout_linear(MOStask* task, BAT *bte
#undef TPE
#endif
-#define scan_loop_linear(TPE, CI_NEXT, TEST) {\
- DeltaTpe(TPE) offset = linear_offset(TPE, task);\
- DeltaTpe(TPE) step = linear_step(TPE, task);\
- for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CI_NEXT(task->ci)) {\
- BUN i = (BUN) (c - first);\
- v = (TPE) (offset + (i * step));\
- /*TODO: change from control to data dependency.*/\
- if (TEST)\
- *o++ = c;\
- }\
-}
-
#define NAME linear
#define TPE bte
#include "mosaic_select_template.h"
diff --git a/monetdb5/modules/mosaic/mosaic_linear_templates.h
b/monetdb5/modules/mosaic/mosaic_linear_templates.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mosaic/mosaic_linear_templates.h
@@ -0,0 +1,24 @@
+static inline void CONCAT6(scan_loop_linear_, TPE, _, CAND_ITER, _, TEST)
+(const bool has_nil, const bool anti, MOStask* task, BUN first, BUN last, TPE
tl, TPE th, bool li, bool hi)
+{
+ (void) has_nil;
+ (void) anti;
+ (void) task;
+ (void) tl;
+ (void) th;
+ (void) li;
+ (void) hi;
+
+ oid* o = task->lb;
+ DeltaTpe(TPE) offset = linear_offset(TPE, task);
+ DeltaTpe(TPE) step = linear_step(TPE, task);
+ for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CAND_ITER(task->ci)) {
+ BUN i = (BUN) (c - first);
+ TPE v = (TPE) (offset + (i * step));
+ (void) v;
+ /*TODO: change from control to data dependency.*/
+ if (CONCAT2(_, TEST))
+ *o++ = c;
+ }
+ task->lb = o;
+}
diff --git a/monetdb5/modules/mosaic/mosaic_prefix.c
b/monetdb5/modules/mosaic/mosaic_prefix.c
--- a/monetdb5/modules/mosaic/mosaic_prefix.c
+++ b/monetdb5/modules/mosaic/mosaic_prefix.c
@@ -116,20 +116,6 @@ MOSlayout_prefix(MOStask* task, BAT *bte
#undef TPE
#endif
-#define scan_loop_prefix(TPE, CI_NEXT, TEST) {\
- MOSBlockHeaderTpe(prefix, TPE)* parameters = (MOSBlockHeaderTpe(prefix,
TPE)*) task->blk;\
- BitVector base = (BitVector) MOScodevectorPrefix(task, TPE);\
- PrefixTpe(TPE) prefix = parameters->prefix;\
- bte suffix_bits = parameters->suffix_bits;\
- for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CI_NEXT(task->ci)) {\
- BUN i = (BUN) (c - first);\
- v = (TPE) (prefix | getBitVector(base,i,suffix_bits));\
- /*TODO: change from control to data dependency.*/\
- if (TEST)\
- *o++ = c;\
- }\
-}
-
#define NAME prefix
#define TPE bte
#include "mosaic_select_template.h"
diff --git a/monetdb5/modules/mosaic/mosaic_prefix_templates.h
b/monetdb5/modules/mosaic/mosaic_prefix_templates.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mosaic/mosaic_prefix_templates.h
@@ -0,0 +1,26 @@
+static inline void CONCAT6(scan_loop_prefix_, TPE, _, CAND_ITER, _, TEST)
+(const bool has_nil, const bool anti, MOStask* task, BUN first, BUN last, TPE
tl, TPE th, bool li, bool hi)
+{
+ (void) has_nil;
+ (void) anti;
+ (void) task;
+ (void) tl;
+ (void) th;
+ (void) li;
+ (void) hi;
+
+ oid* o = task->lb;
+ MOSBlockHeaderTpe(prefix, TPE)* parameters = (MOSBlockHeaderTpe(prefix,
TPE)*) task->blk;
+ BitVector base = (BitVector) MOScodevectorPrefix(task, TPE);
+ PrefixTpe(TPE) prefix = parameters->prefix;
+ bte suffix_bits = parameters->suffix_bits;
+ for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CAND_ITER(task->ci)) {
+ BUN i = (BUN) (c - first);
+ TPE v = (TPE) (prefix | getBitVector(base,i,suffix_bits));
+ (void) v;
+ /*TODO: change from control to data dependency.*/
+ if (CONCAT2(_, TEST))
+ *o++ = c;
+ }
+ task->lb = o;
+}
diff --git a/monetdb5/modules/mosaic/mosaic_raw.c
b/monetdb5/modules/mosaic/mosaic_raw.c
--- a/monetdb5/modules/mosaic/mosaic_raw.c
+++ b/monetdb5/modules/mosaic/mosaic_raw.c
@@ -88,18 +88,6 @@ MOSlayout_raw(MOStask* task, BAT *btech,
#undef TPE
#endif
-#define scan_loop_raw(TPE, CI_NEXT, TEST) \
-{\
- TPE *val= &GET_INIT_raw(task, TPE);\
- for (oid c = canditer_peekprev(task->ci); !is_oid_nil(c) && c < last; c =
CI_NEXT(task->ci)) {\
- BUN i = (BUN) (c - first);\
- v = val[i];\
- /*TODO: change from control to data dependency.*/\
- if (TEST)\
- *o++ = c;\
- }\
-}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list