Changeset: 22ef193dab31 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=22ef193dab31 Modified Files: monetdb5/extras/crackers/crackers.mx monetdb5/extras/crackers/crackers_select_ops.mx monetdb5/extras/crackers/crackers_selectpl_ops.mx Branch: holindex Log Message:
Make concurrent cracking also parallel vectorized. diffs (285 lines): diff --git a/monetdb5/extras/crackers/crackers.mx b/monetdb5/extras/crackers/crackers.mx --- a/monetdb5/extras/crackers/crackers.mx +++ b/monetdb5/extras/crackers/crackers.mx @@ -702,6 +702,80 @@ command thetaselectpl(b:bat[:any_1,:@2], address CRKthetaselectpl_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; + +# new multi-threaded versions + +command selectpl(b:bat[:oid,:@2],l:@2,h:@2, nthreads:int, vector_elements:int):bat[:oid,:@2] +address CRKselectpl_@2_MT +comment "Retrieve the subset using a cracker + index producing preferably a BATview; + nthreads == nil -> original single-threaded implementation, + nthreads == 0 -> revised single-threaded implementation, + nthreads < 0 -> 1st (inferior) version of new multi-threaded implementation, + nthreads > 0 -> 2nd (superior) version of new multi-threaded implementation."; + +command selectpl(b:bat[:oid,:@2],l:@2, nthreads:int, vector_elements:int):bat[:oid,:@2] +address CRKselectplValue_@2_MT +comment "Retrieve the subset using a cracker + index producing preferably a BATview; + nthreads == nil -> original single-threaded implementation, + nthreads == 0 -> revised single-threaded implementation, + nthreads < 0 -> 1st (inferior) version of new multi-threaded implementation, + nthreads > 0 -> 2nd (superior) version of new multi-threaded implementation."; + +command selectpl(b:bat[:oid,:@2],l:@2,h:@2,li:bit,hi:bit, nthreads:int, vector_elements:int):bat[:oid,:@2] +address CRKselectplBounds_@2_MT +comment "Retrieve the subset using a cracker + index producing preferably a BATview; + nthreads == nil -> original single-threaded implementation, + nthreads == 0 -> revised single-threaded implementation, + nthreads < 0 -> 1st (inferior) version of new multi-threaded implementation, + nthreads > 0 -> 2nd (superior) version of new multi-threaded implementation."; + +command uselectpl(b:bat[:any_1,:@2],l:@2,h:@2, nthreads:int, vector_elements:int):bat[:any_1,:void] +address CRKuselectpl_@2_MT +comment "Retrieve the subset using a cracker + index producing preferably a BATview; + nthreads == nil -> original single-threaded implementation, + nthreads == 0 -> revised single-threaded implementation, + nthreads < 0 -> 1st (inferior) version of new multi-threaded implementation, + nthreads > 0 -> 2nd (superior) version of new multi-threaded implementation."; + +command uselectpl(b:bat[:any_1,:@2],l:@2, nthreads:int, vector_elements:int):bat[:any_1,:void] +address CRKuselectplValue_@2_MT +comment "Retrieve the subset using a cracker + index producing preferably a BATview; + nthreads == nil -> original single-threaded implementation, + nthreads == 0 -> revised single-threaded implementation, + nthreads < 0 -> 1st (inferior) version of new multi-threaded implementation, + nthreads > 0 -> 2nd (superior) version of new multi-threaded implementation."; + +command uselectpl(b:bat[:any_1,:@2],l:@2,h:@2,li:bit,hi:bit, nthreads:int, vector_elements:int):bat[:any_1,:void] +address CRKuselectplBounds_@2_MT +comment "Retrieve the subset using a cracker + index producing preferably a BATview; + nthreads == nil -> original single-threaded implementation, + nthreads == 0 -> revised single-threaded implementation, + nthreads < 0 -> 1st (inferior) version of new multi-threaded implementation, + nthreads > 0 -> 2nd (superior) version of new multi-threaded implementation."; + +command thetauselectpl(b:bat[:any_1,:@2],v:@2,op:str, nthreads:int, vector_elements:int):bat[:any_1,:void] +address CRKthetauselectpl_@2_MT +comment "Retrieve the subset using a cracker + index producing preferably a BATview; + nthreads == nil -> original single-threaded implementation, + nthreads == 0 -> revised single-threaded implementation, + nthreads < 0 -> 1st (inferior) version of new multi-threaded implementation, + nthreads > 0 -> 2nd (superior) version of new multi-threaded implementation."; + +command thetaselectpl(b:bat[:any_1,:@2],v:@2,op:str, nthreads:int, vector_elements:int):bat[:any_1,:@2] +address CRKthetaselectpl_@2_MT +comment "Retrieve the subset using a cracker + index producing preferably a BATview; + nthreads == nil -> original single-threaded implementation, + nthreads == 0 -> revised single-threaded implementation, + nthreads < 0 -> 1st (inferior) version of new multi-threaded implementation, + nthreads > 0 -> 2nd (superior) version of new multi-threaded implementation."; @ @= JoinSelect command joinuselect( right:bat[:oid,:@2], l:@2, h:@2, li:bit, hi:bit, left:bat[:oid,:void] ):bat[:oid,:void] diff --git a/monetdb5/extras/crackers/crackers_select_ops.mx b/monetdb5/extras/crackers/crackers_select_ops.mx --- a/monetdb5/extras/crackers/crackers_select_ops.mx +++ b/monetdb5/extras/crackers/crackers_select_ops.mx @@ -131,7 +131,7 @@ CRKselectValue_@1(int *vid, int *bid, @1 str CRKselectValue_@1_MT(int *vid, int *bid, @1 *value, const int *nthreads, const int *vector_elements){ bit inclusive = TRUE; - return CRKuselectBounds_@1_MT(vid, bid, value, value, &inclusive, &inclusive, nthreads, vector_elements); + return CRKselectBounds_@1_MT(vid, bid, value, value, &inclusive, &inclusive, nthreads, vector_elements); } str diff --git a/monetdb5/extras/crackers/crackers_selectpl_ops.mx b/monetdb5/extras/crackers/crackers_selectpl_ops.mx --- a/monetdb5/extras/crackers/crackers_selectpl_ops.mx +++ b/monetdb5/extras/crackers/crackers_selectpl_ops.mx @@ -65,6 +65,15 @@ crackers_export str CRKuselectpl_@1(int crackers_export str CRKthetaselectpl_@1(int *vid, int *bid, @1 *val, str *op); crackers_export str CRKthetauselectpl_@1(int *vid, int *bid, @1 *val, str *op); crackers_export str CRKsumplBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh); +/* new multi-threaded versions */ +crackers_export str CRKselectplBounds_@1_MT(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, const int *nthreads, const int *vector_elements); +crackers_export str CRKuselectplBounds_@1_MT(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, const int *nthreads, const int *vector_elements); +crackers_export str CRKselectplValue_@1_MT(int *vid, int *bid, @1 *value, const int *nthreads, const int *vector_elements); +crackers_export str CRKuselectplValue_@1_MT(int *vid, int *bid, @1 *value, const int *nthreads, const int *vector_elements); +crackers_export str CRKselectpl_@1_MT(int *vid, int *bid, @1 *low, @1 *hgh, const int *nthreads, const int *vector_elements); +crackers_export str CRKuselectpl_@1_MT(int *vid, int *bid, @1 *low, @1 *hgh, const int *nthreads, const int *vector_elements); +crackers_export str CRKthetaselectpl_@1_MT(int *vid, int *bid, @1 *val, str *op, const int *nthreads, const int *vector_elements); +crackers_export str CRKthetauselectpl_@1_MT(int *vid, int *bid, @1 *val, str *op, const int *nthreads, const int *vector_elements); @ @c @@ -86,53 +95,74 @@ crackers_export str CRKsumplBounds_@1(in * @- Exported functions */ @= SelectplFunctions_impl - str -CRKselectplBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh){ +CRKselectplBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh){ + return CRKselectplBounds_@1_MT(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, &int_nil, &int_nil); +} +str +CRKselectplBounds_@1_MT(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, const int *nthreads, const int *vector_elements){ if (@2_EQ(low,ATOMnilptr(TYPE_@1),@3@1)) - return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh, TRUE); + return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh, TRUE, *nthreads, *vector_elements); else if (@2_EQ(hgh,ATOMnilptr(TYPE_@1),@3@1)) - return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow, TRUE); + return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow, TRUE, *nthreads, *vector_elements); else - return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, TRUE); + return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, TRUE, *nthreads, *vector_elements); } - str CRKuselectplBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh){ + return CRKuselectplBounds_@1_MT(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, &int_nil, &int_nil); +} +str +CRKuselectplBounds_@1_MT(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, const int *nthreads, const int *vector_elements){ if (@2_EQ(low,ATOMnilptr(TYPE_@1),@3@1)) - return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh, FALSE); + return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh, FALSE, *nthreads, *vector_elements); else if (@2_EQ(hgh,ATOMnilptr(TYPE_@1),@3@1)) - return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow, FALSE); + return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow, FALSE, *nthreads, *vector_elements); else - return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, FALSE); + return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, FALSE, *nthreads, *vector_elements); } - str CRKselectplValue_@1(int *vid, int *bid, @1 *value){ + return CRKselectplValue_@1_MT(vid, bid, value, &int_nil, &int_nil); +} +str +CRKselectplValue_@1_MT(int *vid, int *bid, @1 *value, const int *nthreads, const int *vector_elements){ bit inclusive = TRUE; - return CRKuselectplBounds_@1(vid, bid, value, value, &inclusive, &inclusive); + return CRKselectplBounds_@1_MT(vid, bid, value, value, &inclusive, &inclusive, nthreads, vector_elements); } - str CRKuselectplValue_@1(int *vid, int *bid, @1 *value){ + return CRKuselectplValue_@1_MT(vid, bid, value, &int_nil, &int_nil); +} +str +CRKuselectplValue_@1_MT(int *vid, int *bid, @1 *value, const int *nthreads, const int *vector_elements){ bit inclusive = TRUE; - return CRKuselectplBounds_@1(vid, bid, value, value, &inclusive, &inclusive); + return CRKuselectplBounds_@1_MT(vid, bid, value, value, &inclusive, &inclusive, nthreads, vector_elements); } - str CRKselectpl_@1(int *vid, int *bid, @1 *low, @1 *hgh){ + return CRKselectpl_@1_MT(vid, bid, low, hgh, &int_nil, &int_nil); +} +str +CRKselectpl_@1_MT(int *vid, int *bid, @1 *low, @1 *hgh, const int *nthreads, const int *vector_elements){ bit inclusive = TRUE; - return CRKselectplBounds_@1(vid, bid, low, hgh, &inclusive, &inclusive); + return CRKselectplBounds_@1_MT(vid, bid, low, hgh, &inclusive, &inclusive, nthreads, vector_elements); } - str CRKuselectpl_@1(int *vid, int *bid, @1 *low, @1 *hgh){ + return CRKuselectpl_@1_MT(vid, bid, low, hgh, &int_nil, &int_nil); +} +str +CRKuselectpl_@1_MT(int *vid, int *bid, @1 *low, @1 *hgh, const int *nthreads, const int *vector_elements){ bit inclusive = TRUE; - return CRKuselectplBounds_@1(vid, bid, low, hgh, &inclusive, &inclusive); + return CRKuselectplBounds_@1_MT(vid, bid, low, hgh, &inclusive, &inclusive, nthreads, vector_elements); } - str CRKthetaselectpl_@1(int *vid, int *bid, @1 *val, str *OP){ + return CRKthetaselectpl_@1_MT(vid, bid, val, OP, &int_nil, &int_nil); +} +str +CRKthetaselectpl_@1_MT(int *vid, int *bid, @1 *val, str *OP, const int *nthreads, const int *vector_elements){ ptr nilptr = ATOMnilptr(TYPE_@1); char *op = *OP; bit lin = TRUE, rin = TRUE; @@ -151,11 +181,14 @@ CRKthetaselectpl_@1(int *vid, int *bid, throw(MAL, "crackers.thetaselectpl", "unknown operator"); } - return CRKselectplBounds_@1(vid, bid, low, high, &lin, &rin); + return CRKselectplBounds_@1_MT(vid, bid, low, high, &lin, &rin, nthreads, vector_elements); } - str CRKthetauselectpl_@1(int *vid, int *bid, @1 *val, str *OP){ + return CRKthetauselectpl_@1_MT(vid, bid, val, OP, &int_nil, &int_nil); +} +str +CRKthetauselectpl_@1_MT(int *vid, int *bid, @1 *val, str *OP, const int *nthreads, const int *vector_elements){ ptr nilptr = ATOMnilptr(TYPE_@1); char *op = *OP; bit lin = TRUE, rin = TRUE; @@ -173,7 +206,7 @@ CRKthetauselectpl_@1(int *vid, int *bid, throw(MAL, "crackers.thetauselectpl", "unknown operator"); } - return CRKuselectplBounds_@1(vid, bid, low, high, &lin, &rin); + return CRKuselectplBounds_@1_MT(vid, bid, low, high, &lin, &rin, nthreads, vector_elements); } str CRKsumplBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh){ @@ -223,9 +256,9 @@ CRKsumplBounds_@1(int *vid, int *bid, @1 @= crkTwoLTree /*CRACK in two pieces cl1-ch1 using >incLow bound*/ if (*inclusiveLow == TRUE) - CRKcrackUnorderedZero@2_RE_@1(b,*low, cl1, ch1,&vl, int_nil, int_nil); + CRKcrackUnorderedZero@2_RE_@1(b,*low, cl1, ch1,&vl, nthreads, vector_elements); else - CRKcrackUnorderedZero@2_LE_@1(b,*low, cl1, ch1,&vl, int_nil, int_nil); + CRKcrackUnorderedZero@2_LE_@1(b,*low, cl1, ch1,&vl, nthreads, vector_elements); if (vl < cl1){ /*then the left piece is empty*/ @@ -244,9 +277,9 @@ CRKsumplBounds_@1(int *vid, int *bid, @1 @= crkTwoRTree /*CRACK in two pieces cl2-ch2 using <incHgh bound*/ if (*inclusiveHgh == TRUE) - CRKcrackUnorderedZero@2_LE_@1(b,*hgh, cl2, ch2,&vh, int_nil, int_nil); + CRKcrackUnorderedZero@2_LE_@1(b,*hgh, cl2, ch2,&vh, nthreads, vector_elements); else - CRKcrackUnorderedZero@2_RE_@1(b,*hgh, cl2, ch2,&vh, int_nil, int_nil); + CRKcrackUnorderedZero@2_RE_@1(b,*hgh, cl2, ch2,&vh, nthreads, vector_elements); if (vh < cl2) /*then the left piece is empty*/ @@ -1087,7 +1120,7 @@ To do that, we first search the index to know and which parts we have to crack. Then we crack, if necessary, the appropriate pieces, update the index and return the result */ static str -CRKRangeTree_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, bit tail){ +CRKRangeTree_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, bit tail, int nthreads, int vector_elements){ @:RangeSelectBody(@1,@2,@3,@4,)@ } static str @@ -1096,7 +1129,7 @@ CRKRangeSumTree_@1(int *vid, int *bid, @ } static str -CRKRangeLeftNilTree_@1(int *vid, int *bid, @1 *hgh, bit *inclusiveHgh, bit tail){ +CRKRangeLeftNilTree_@1(int *vid, int *bid, @1 *hgh, bit *inclusiveHgh, bit tail, int nthreads, int vector_elements){ BAT *b,*c,*bo; BAT *view; int m; @@ -1248,7 +1281,7 @@ CRKRangeLeftNilTree_@1(int *vid, int *bi } static str -CRKRangeRightNilTree_@1(int *vid, int *bid, @1 *low, bit *inclusiveLow, bit tail){ +CRKRangeRightNilTree_@1(int *vid, int *bid, @1 *low, bit *inclusiveLow, bit tail, int nthreads, int vector_elements){ BAT *b,*c,*bo; BAT *view; int m; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list