Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SegString.hash() to SegString.siphash() #1556

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ArgSortMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ module ArgSortMsg
}

proc incrementalArgSort(s: SegString, iv: [?aD] int): [] int throws {
var hashes = s.hash();
var hashes = s.siphash();
var newHashes: [aD] 2*uint;
forall (nh, idx) in zip(newHashes, iv) with (var agg = newSrcAggregator((2*uint))) {
agg.copy(nh, hashes[idx]);
Expand Down
10 changes: 5 additions & 5 deletions src/SegmentedArray.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ module SegmentedArray {

/* Apply a hash function to all strings. This is useful for grouping
and set membership. The hash used is SipHash128.*/
proc hash() throws {
proc siphash() throws {
return computeOnSegments(offsets.a, values.a, SegFunction.SipHash128, 2*uint(64));
}

Expand All @@ -348,7 +348,7 @@ module SegmentedArray {
// Hash all strings
saLogger.debug(getModuleName(),getRoutineName(),getLineNumber(), "Hashing strings");
if logLevel == LogLevel.DEBUG { t.start(); }
var hashes = this.hash();
var hashes = this.siphash();

if logLevel == LogLevel.DEBUG {
t.stop();
Expand Down Expand Up @@ -1113,8 +1113,8 @@ module SegmentedArray {
errorClass="ArgumentError");
}
if useHash {
const lh = lss.hash();
const rh = rss.hash();
const lh = lss.siphash();
const rh = rss.siphash();
return if polarity then (lh == rh) else (lh != rh);
}
ref oD = lss.offsets.aD;
Expand Down Expand Up @@ -1263,7 +1263,7 @@ module SegmentedArray {
var truth: [mainStr.offsets.aD] bool;
return truth;
}
return in1d(mainStr.hash(), testStr.hash(), invert);
return in1d(mainStr.siphash(), testStr.siphash(), invert);
}

proc concat(s1: [] int, v1: [] uint(8), s2: [] int, v2: [] uint(8)) throws {
Expand Down
2 changes: 1 addition & 1 deletion src/SegmentedMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ module SegmentedMsg {
select objtype {
when "str" {
var strings = getSegString(name, st);
var hashes = strings.hash();
var hashes = strings.siphash();
var name1 = st.nextName();
var hash1 = st.addEntry(name1, hashes.size, uint);
var name2 = st.nextName();
Expand Down
2 changes: 1 addition & 1 deletion src/Unique.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ module Unique
var truth: [aD] bool;
var perm: [aD] int;
if SegmentedArrayUseHash {
var hashes = str.hash();
var hashes = str.siphash();
var sorted: [aD] 2*uint;
forall (s, p, sp) in zip(sorted, perm, radixSortLSD(hashes)) {
(s, p) = sp;
Expand Down
2 changes: 1 addition & 1 deletion src/UniqueMsg.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ module UniqueMsg
when "str" {
var (myNames, _) = name.splitMsgToTuple('+', 2);
var g = getSegString(myNames, st);
hashes ^= rotl(g.hash(), i);
hashes ^= rotl(g.siphash(), i);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/UnitTestIn1d.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ prototype module UnitTestIn1d
var d: Diags;
d.start();
// returns a boolean vector
var truth = in1dAr2PerLocAssoc(str1.hash(), str2.hash());
var truth = in1dAr2PerLocAssoc(str1.siphash(), str2.siphash());
d.stop("in1d (associative domain)");
d.start();
var truth2 = in1dSort(str1.hash(), str2.hash());
var truth2 = in1dSort(str1.siphash(), str2.siphash());
d.stop("in1d (sort-based)");
writeln("Results of both strategies match? >>> ", && reduce (truth == truth2), " <<<");
if printExpected then writeln("<<< #str1[i] in str2 = ", + reduce truth, " (expected ", expected, ")");try! stdout.flush();
Expand Down