-
Notifications
You must be signed in to change notification settings - Fork 113
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
[fix/180] Fix offset for vector instructions that operate in private memory space #181
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3c38210
[test] Add unit-tests for private vector operations
stratika a355a34
[fix] Fix offset for vector operations in private memory
stratika d4e533f
[refactor] Unify the name of getLength method for all vector types
stratika b9d99ab
Merge branch 'develop' into fix/180
stratika 6db6cbc
[refactor] Applied comments from code review
stratika File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2013-2020, APT Group, Department of Computer Science, | ||
* Copyright (c) 2013-2022, APT Group, Department of Computer Science, | ||
* The University of Manchester. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
@@ -34,6 +34,7 @@ | |
import uk.ac.manchester.tornado.api.collections.types.VectorDouble2; | ||
import uk.ac.manchester.tornado.api.collections.types.VectorDouble3; | ||
import uk.ac.manchester.tornado.api.collections.types.VectorDouble4; | ||
import uk.ac.manchester.tornado.api.collections.types.VectorDouble8; | ||
import uk.ac.manchester.tornado.unittests.common.TornadoTestBase; | ||
|
||
public class TestDoubles extends TornadoTestBase { | ||
|
@@ -318,4 +319,120 @@ public void testVectorDouble4() { | |
} | ||
} | ||
|
||
public static void testPrivateVectorDouble2(VectorDouble2 output) { | ||
VectorDouble2 vectorDouble2 = new VectorDouble2(output.getLength()); | ||
|
||
for (int i = 0; i < vectorDouble2.getLength(); i++) { | ||
vectorDouble2.set(i, new Double2(i, i)); | ||
} | ||
|
||
Double2 sum = new Double2(0, 0); | ||
|
||
for (int i = 0; i < vectorDouble2.getLength(); i++) { | ||
Double2 f = vectorDouble2.get(i); | ||
sum = Double2.add(f, sum); | ||
} | ||
|
||
output.set(0, sum); | ||
} | ||
|
||
@Test | ||
public void privateVectorDouble2() { | ||
int size = 16; | ||
VectorDouble2 sequentialOutput = new VectorDouble2(size); | ||
VectorDouble2 tornadoOutput = new VectorDouble2(size); | ||
|
||
TaskSchedule ts = new TaskSchedule("s0"); | ||
ts.task("t0", TestDoubles::testPrivateVectorDouble2, tornadoOutput); | ||
ts.streamOut(tornadoOutput); | ||
ts.execute(); | ||
|
||
testPrivateVectorDouble2(sequentialOutput); | ||
|
||
for (int i = 0; i < size; i++) { | ||
assertEquals(sequentialOutput.get(i).getX(), tornadoOutput.get(i).getX(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getY(), tornadoOutput.get(i).getY(), 0.001); | ||
} | ||
} | ||
|
||
public static void testPrivateVectorDouble4(VectorDouble4 output) { | ||
VectorDouble4 vectorDouble4 = new VectorDouble4(output.getLength()); | ||
|
||
for (int i = 0; i < vectorDouble4.getLength(); i++) { | ||
vectorDouble4.set(i, new Double4(i, i, i, i)); | ||
} | ||
|
||
Double4 sum = new Double4(0, 0, 0, 0); | ||
|
||
for (int i = 0; i < vectorDouble4.getLength(); i++) { | ||
Double4 f = vectorDouble4.get(i); | ||
sum = Double4.add(f, sum); | ||
} | ||
|
||
output.set(0, sum); | ||
} | ||
|
||
@Test | ||
public void privateVectorDouble4() { | ||
int size = 16; | ||
VectorDouble4 sequentialOutput = new VectorDouble4(size); | ||
VectorDouble4 tornadoOutput = new VectorDouble4(size); | ||
|
||
TaskSchedule ts = new TaskSchedule("s0"); | ||
ts.task("t0", TestDoubles::testPrivateVectorDouble4, tornadoOutput); | ||
ts.streamOut(tornadoOutput); | ||
ts.execute(); | ||
|
||
testPrivateVectorDouble4(sequentialOutput); | ||
|
||
for (int i = 0; i < size; i++) { | ||
assertEquals(sequentialOutput.get(i).getX(), tornadoOutput.get(i).getX(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getY(), tornadoOutput.get(i).getY(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getZ(), tornadoOutput.get(i).getZ(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getW(), tornadoOutput.get(i).getW(), 0.001); | ||
} | ||
} | ||
|
||
public static void testPrivateVectorDouble8(VectorDouble8 output) { | ||
VectorDouble8 vectorDouble8 = new VectorDouble8(output.getLength()); | ||
|
||
for (int i = 0; i < vectorDouble8.getLength(); i++) { | ||
vectorDouble8.set(i, new Double8(i, i, i, i, i, i, i, i)); | ||
} | ||
|
||
Double8 sum = new Double8(0, 0, 0, 0, 0, 0, 0, 0); | ||
|
||
for (int i = 0; i < vectorDouble8.getLength(); i++) { | ||
Double8 f = vectorDouble8.get(i); | ||
sum = Double8.add(f, sum); | ||
} | ||
|
||
output.set(0, sum); | ||
} | ||
|
||
@Test | ||
public void privateVectorDouble8() { | ||
int size = 16; | ||
VectorDouble8 sequentialOutput = new VectorDouble8(16); | ||
VectorDouble8 tornadoOutput = new VectorDouble8(16); | ||
|
||
TaskSchedule ts = new TaskSchedule("s0"); | ||
ts.task("t0", TestDoubles::testPrivateVectorDouble8, tornadoOutput); | ||
ts.streamOut(tornadoOutput); | ||
ts.execute(); | ||
|
||
testPrivateVectorDouble8(sequentialOutput); | ||
|
||
for (int i = 0; i < size; i++) { | ||
assertEquals(sequentialOutput.get(i).getS0(), tornadoOutput.get(i).getS0(), 0.001); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a constant for the delta value |
||
assertEquals(sequentialOutput.get(i).getS1(), tornadoOutput.get(i).getS1(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getS2(), tornadoOutput.get(i).getS2(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getS3(), tornadoOutput.get(i).getS3(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getS4(), tornadoOutput.get(i).getS4(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getS5(), tornadoOutput.get(i).getS5(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getS6(), tornadoOutput.get(i).getS6(), 0.001); | ||
assertEquals(sequentialOutput.get(i).getS7(), tornadoOutput.get(i).getS7(), 0.001); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename
s
toindex