Skip to content

Commit

Permalink
Update Sort comparators for Chapel 2.2 (#3750)
Browse files Browse the repository at this point in the history
* update comparators for Chapel 2.2

Signed-off-by: Jade Abraham <[email protected]>

* fix makefile for docs

Signed-off-by: Jade Abraham <[email protected]>

* remove gitignores

Signed-off-by: Jade Abraham <[email protected]>

* fix missing *

Signed-off-by: Jade Abraham <[email protected]>

* avoid compat module issues

Signed-off-by: Jade Abraham <[email protected]>

---------

Signed-off-by: Jade Abraham <[email protected]>
  • Loading branch information
jabraham17 authored Sep 9, 2024
1 parent 906bdb2 commit 4db3469
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 20 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ ifeq ($(shell expr $(CHPL_MINOR) \>= 2),1)
ARKOUDA_COMPAT_MODULES += -M $(ARKOUDA_SOURCE_DIR)/compat/ge-22
endif

ifeq ($(shell expr $(CHPL_MINOR) \>= 2),1)
ARKOUDA_KEYPART_FLAG := -suseKeyPartStatus=true
endif

ifeq ($(shell expr $(CHPL_MINOR) \<= 1),1)
ARKOUDA_RW_DEFAULT_FLAG := -sOpenReaderLockingDefault=false -sOpenWriterLockingDefault=false
endif
Expand All @@ -391,7 +395,7 @@ SERVER_CONFIG_SCRIPT=$(ARKOUDA_SOURCE_DIR)/parseServerConfig.py
$(ARKOUDA_MAIN_MODULE): check-deps register-commands $(ARROW_UTIL_O) $(ARROW_READ_O) $(ARROW_WRITE_O) $(ARKOUDA_SOURCES) $(ARKOUDA_MAKEFILES)
$(eval MOD_GEN_OUT=$(shell python3 $(SERVER_CONFIG_SCRIPT) $(ARKOUDA_CONFIG_FILE) $(ARKOUDA_REGISTRATION_CONFIG) $(ARKOUDA_SOURCE_DIR)))

$(CHPL) $(CHPL_DEBUG_FLAGS) $(PRINT_PASSES_FLAGS) $(REGEX_MAX_CAPTURES_FLAG) $(OPTIONAL_SERVER_FLAGS) $(CHPL_FLAGS_WITH_VERSION) $(CHPL_COMPAT_FLAGS) $(ARKOUDA_MAIN_SOURCE) $(ARKOUDA_COMPAT_MODULES) $(ARKOUDA_SERVER_USER_MODULES) $(MOD_GEN_OUT) $(ARKOUDA_RW_DEFAULT_FLAG) $(ARKOUDA_REGISTRY_DIR)/Commands.chpl -I$(ARKOUDA_SOURCE_DIR)/parquet -o $@
$(CHPL) $(CHPL_DEBUG_FLAGS) $(PRINT_PASSES_FLAGS) $(REGEX_MAX_CAPTURES_FLAG) $(OPTIONAL_SERVER_FLAGS) $(CHPL_FLAGS_WITH_VERSION) $(CHPL_COMPAT_FLAGS) $(ARKOUDA_MAIN_SOURCE) $(ARKOUDA_COMPAT_MODULES) $(ARKOUDA_SERVER_USER_MODULES) $(MOD_GEN_OUT) $(ARKOUDA_RW_DEFAULT_FLAG) $(ARKOUDA_KEYPART_FLAG) $(ARKOUDA_REGISTRY_DIR)/Commands.chpl -I$(ARKOUDA_SOURCE_DIR)/parquet -o $@

CLEAN_TARGETS += arkouda-clean
.PHONY: arkouda-clean
Expand Down Expand Up @@ -474,7 +478,7 @@ doc-server: ${DOC_DIR} $(DOC_SERVER_OUTPUT_DIR)/index.html
$(DOC_SERVER_OUTPUT_DIR)/index.html: $(ARKOUDA_SOURCES) $(ARKOUDA_MAKEFILES) | $(DOC_SERVER_OUTPUT_DIR)
@echo "Building documentation for: Server"
@# Build the documentation to the Chapel output directory
$(CHPLDOC) $(CHPLDOC_FLAGS) $(ARKOUDA_MAIN_SOURCE) -o $(DOC_SERVER_OUTPUT_DIR)
$(CHPLDOC) $(CHPLDOC_FLAGS) $(ARKOUDA_MAIN_SOURCE) $(ARKOUDA_SOURCE_DIR)/compat/ge-22/* -o $(DOC_SERVER_OUTPUT_DIR)
@# Create the .nojekyll file needed for github pages in the Chapel output directory
touch $(DOC_SERVER_OUTPUT_DIR)/.nojekyll
@echo "Completed building documentation for: Server"
Expand Down
16 changes: 8 additions & 8 deletions src/ArgSortMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module ArgSortMsg

use Time;
use Math only;
private use Sort;
private use ArkoudaSortCompat;

use Reflection only;

Expand Down Expand Up @@ -39,9 +39,9 @@ module ArgSortMsg

proc dynamicTwoArrayRadixSort(ref Data:[], comparator:?rec=new DefaultComparator()) {
if Data._instance.isDefaultRectangular() {
Sort.TwoArrayRadixSort.twoArrayRadixSort(Data, comparator);
ArkoudaSortCompat.TwoArrayRadixSort.twoArrayRadixSort(Data, comparator);
} else {
Sort.TwoArrayDistributedRadixSort.twoArrayDistributedRadixSort(Data, comparator);
ArkoudaSortCompat.TwoArrayDistributedRadixSort.twoArrayDistributedRadixSort(Data, comparator);
}
}

Expand Down Expand Up @@ -86,7 +86,7 @@ module ArgSortMsg
// (isInt(x(0)) || isUint(x(0)) || isReal(x(0))) {

import Reflection.canResolveMethod;
record ContrivedComparator {
record ContrivedComparator: keyPartComparator {
const dc = new DefaultComparator();
proc keyPart(a, i: int) {
if canResolveMethod(dc, "keyPart", a, 0) {
Expand Down Expand Up @@ -123,9 +123,9 @@ module ArgSortMsg
part = makePart(x[1]);
}
if i > x[0].size {
return (-1, 0:uint(64));
return (keyPartStatus.pre, 0:uint(64));
} else {
return (0, part);
return (keyPartStatus.returned, part);
}
} else {
for param j in 0..<x.size {
Expand All @@ -134,9 +134,9 @@ module ArgSortMsg
}
}
if i >= x.size {
return (-1, 0:uint(64));
return (keyPartStatus.pre, 0:uint(64));
} else {
return (0, part);
return (keyPartStatus.returned, part);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/RadixSortLSD.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@ module RadixSortLSD
use RangeChunk;
use Logging;
use ServerConfig;
use ArkoudaSortCompat except isSorted;

private config const logLevel = ServerConfig.logLevel;
private config const logChannel = ServerConfig.logChannel;
const rsLogger = new Logger(logLevel, logChannel);

record KeysComparator {
record KeysComparator: keyComparator {
inline proc key(k) { return k; }
}

record KeysRanksComparator {
record KeysRanksComparator: keyComparator {
inline proc key(kr) { const (k, _) = kr; return k; }
}

Expand Down
4 changes: 2 additions & 2 deletions src/SegStringSort.chpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SegStringSort {
use SegmentedString;
use Sort;
use ArkoudaSortCompat;
use Time;
use IO;
use CTypes;
Expand All @@ -26,7 +26,7 @@ module SegStringSort {
private config const logChannel = ServerConfig.logChannel;
const ssLogger = new Logger(logLevel, logChannel);

record StringIntComparator {
record StringIntComparator: keyPartComparator {
proc keyPart((a0,_): (string, int), in i: int) {
// Just run the default comparator on the string
return (new DefaultComparator()).keyPart(a0, i);
Expand Down
6 changes: 3 additions & 3 deletions src/SortMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module SortMsg

use Time;
use Math only;
use Sort only;
use ArkoudaSortCompat only relativeComparator;
use Search only;
use Reflection;
use ServerErrors;
Expand Down Expand Up @@ -201,14 +201,14 @@ module SortMsg
return new MsgTuple(repMsg, MsgType.NORMAL);
}

record leftCmp {
record leftCmp: relativeComparator {
proc compare(a: real, b: real): int {
if a < b then return -1;
else return 1;
}
}

record rightCmp {
record rightCmp: relativeComparator {
proc compare(a: real, b: real): int {
if a <= b then return -1;
else return 1;
Expand Down
1 change: 0 additions & 1 deletion src/compat/eq-20/.gitignore

This file was deleted.

13 changes: 13 additions & 0 deletions src/compat/eq-20/ArkoudaSortCompat.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module ArkoudaSortCompat {
public use Sort;

interface keyComparator {}
interface keyPartComparator {}
interface relativeComparator {}

module keyPartStatus {
proc pre param do return -1;
proc returned param do return 0;
proc post param do return 1;
}
}
1 change: 0 additions & 1 deletion src/compat/eq-21/.gitignore

This file was deleted.

13 changes: 13 additions & 0 deletions src/compat/eq-21/ArkoudaSortCompat.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module ArkoudaSortCompat {
public use Sort;

interface keyComparator {}
interface keyPartComparator {}
interface relativeComparator {}

module keyPartStatus {
proc pre param do return -1;
proc returned param do return 0;
proc post param do return 1;
}
}
1 change: 0 additions & 1 deletion src/compat/ge-22/.gitignore

This file was deleted.

3 changes: 3 additions & 0 deletions src/compat/ge-22/ArkoudaSortCompat.chpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ArkoudaSortCompat {
public use Sort;
}

0 comments on commit 4db3469

Please sign in to comment.