Skip to content

Commit 920f52c

Browse files
[GrCUDA-66] fix arity deprecation (#27)
* removed deprecation warning for arity exception * updated changelog
1 parent f6a457d commit 920f52c

File tree

15 files changed

+51
-41
lines changed

15 files changed

+51
-41
lines changed

CHANGELOG.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
# 2021-11-29
2+
3+
* Removed deprecation warning for Truffle's ArityException.
4+
15
# 2021-11-21
26

37
* Enabled support for cuSPARSE
4-
* Operations with sparse matrices from cuSPARSE library are now supported
5-
* **Known limitation:** Not all data types are supported: in particular Tgemvi does not support double data types
6-
(both complex and not)
7-
* Concurrent operations on parallel streams were analyzed using Nvidia Profiler
8-
9-
=======
8+
* Added support for CSR and COO `spmv` and `gemvi`.
9+
* **Known limitation:** Tgemvi works only with single-precision floating-point arithmetics.
1010

1111
# 2021-11-17
1212

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/cudalibraries/cuml/CUMLRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public Object call(Object[] arguments) throws ArityException {
128128
@TruffleBoundary
129129
public Object call(Object[] arguments) throws ArityException {
130130
checkArgumentLength(arguments, 2);
131-
try (UnsafeHelper.Integer64Object handle = UnsafeHelper.createInteger64Object()) {
131+
try {
132132
long stream_handle = expectLong(arguments[0]);
133133
long streamID = expectLong(arguments[1]);
134134
Object result = INTEROP.execute(cumlSetStreamFunctionNFI, stream_handle, streamID);

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/functions/DeviceArrayCopyFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Object execute(Object[] arguments,
102102
numElements = extractNumber(arguments[1], numElementsAccess);
103103
} else {
104104
CompilerDirectives.transferToInterpreter();
105-
throw ArityException.create(1, arguments.length);
105+
throw ArityException.create(1, 2, arguments.length);
106106
}
107107
// Obtain what kind of copy (pointer or array) should be executed.
108108
// By default, see if we can use the fast CUDA memcpy: we cannot use it if the source and target arrays

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/functions/DeviceArrayFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public DeviceArrayFunction(AbstractGrCUDAExecutionContext grCUDAExecutionContext
7777
@TruffleBoundary
7878
public Object call(Object[] arguments) throws ArityException, UnsupportedTypeException {
7979
if (arguments.length < 1) {
80-
throw ArityException.create(1, arguments.length);
80+
throw ArityException.create(1, 2, arguments.length);
8181
}
8282
String typeName = expectString(arguments[0], "first argument of DeviceArray must be string (type name)");
8383
Type elementType;

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/functions/Function.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,14 @@ public static long expectPositiveLong(Object number) throws UnsupportedTypeExcep
112112
public static void checkArgumentLength(Object[] arguments, int expected) throws ArityException {
113113
if (arguments.length != expected) {
114114
CompilerDirectives.transferToInterpreter();
115-
throw ArityException.create(expected, arguments.length);
115+
throw ArityException.create(expected, expected, arguments.length);
116+
}
117+
}
118+
119+
public static void checkArgumentLength(Object[] arguments, int minExpected, int maxExpected) throws ArityException {
120+
if (arguments.length < minExpected || arguments.length > maxExpected) {
121+
CompilerDirectives.transferToInterpreter();
122+
throw ArityException.create(minExpected, maxExpected, arguments.length);
116123
}
117124
}
118125

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/functions/MapDeviceArrayFunction.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public Object execute(Object[] arguments,
227227
@Cached MapArrayNode mapNode) throws ArityException, UnsupportedTypeException {
228228
if (arguments.length < 1) {
229229
CompilerDirectives.transferToInterpreter();
230-
throw ArityException.create(1, arguments.length);
230+
throw ArityException.create(1, 2, arguments.length);
231231
}
232232
String typeName;
233233
try {
@@ -244,12 +244,11 @@ public Object execute(Object[] arguments,
244244
}
245245
if (arguments.length == 1) {
246246
return new TypedMapDeviceArrayFunction(grCUDAExecutionContext, elementType);
247-
} else {
248-
if (arguments.length != 2) {
249-
CompilerDirectives.transferToInterpreter();
250-
throw ArityException.create(2, arguments.length);
251-
}
247+
} else if (arguments.length == 2) {
252248
return mapNode.execute(arguments[1], elementType, grCUDAExecutionContext);
249+
} else {
250+
CompilerDirectives.transferToInterpreter();
251+
throw ArityException.create(1, 2, arguments.length);
253252
}
254253
}
255254
}

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/functions/TypedDeviceArrayFunction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ public TypedDeviceArrayFunction(AbstractGrCUDAExecutionContext grCUDAExecutionCo
6161
public Object call(Object[] arguments) throws ArityException, UnsupportedTypeException {
6262
if (arguments.length < 1) {
6363
CompilerDirectives.transferToInterpreter();
64-
throw ArityException.create(1, arguments.length);
64+
// FIXME: the maximum number of arguments is unbound (as each argument is a dimension of a N-dimensional tensor).
65+
// Truffle currently uses -1 to handle an unbound number of arguments;
66+
throw ArityException.create(1, -1, arguments.length);
6567
}
6668
return DeviceArrayFunction.createArray(arguments, 0, elementType, grCUDAExecutionContext);
6769
}

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/functions/TypedMapDeviceArrayFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public Object execute(Object[] arguments,
6464
@Cached MapArrayNode mapNode) throws ArityException {
6565
if (arguments.length != 1) {
6666
CompilerDirectives.transferToInterpreter();
67-
throw ArityException.create(1, arguments.length);
67+
throw ArityException.create(1, 1, arguments.length);
6868
}
6969
return mapNode.execute(arguments[0], elementType, grCUDAExecutionContext);
7070
}

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/functions/map/MapFunction.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public MappedFunction map(Object function, Object... arguments) throws ArityExce
120120
static void checkArity(Object[] arguments, int expectedArity) throws ArityException {
121121
if (arguments.length != expectedArity) {
122122
CompilerDirectives.transferToInterpreter();
123-
throw ArityException.create(expectedArity, arguments.length);
123+
throw ArityException.create(expectedArity, expectedArity, arguments.length);
124124
}
125125
}
126126

@@ -175,7 +175,9 @@ static MapFunctionBase readMemberArg(MapFunction receiver, String member) {
175175
static MapFunctionBase readMemberSize(MapFunction receiver, String member) {
176176
return new MapFunctionBase(arguments -> {
177177
if (arguments.length == 0) {
178-
throw ArityException.create(1, 0);
178+
// FIXME: the maximum number of arguments is unbound.
179+
// Truffle currently uses -1 to handle an unbound number of arguments;
180+
throw ArityException.create(1, -1, 0);
179181
}
180182
try {
181183
return receiver.size((MapArgObject) arguments[0], Arrays.copyOfRange(arguments, 1, arguments.length, MapArgObject[].class));
@@ -189,7 +191,9 @@ static MapFunctionBase readMemberSize(MapFunction receiver, String member) {
189191
static MapFunctionBase readMemberValue(MapFunction receiver, String member) {
190192
return new MapFunctionBase(arguments -> {
191193
if (arguments.length < 1) {
192-
throw ArityException.create(1, arguments.length);
194+
// FIXME: the maximum number of arguments is unbound.
195+
// Truffle currently uses -1 to handle an unbound number of arguments;
196+
throw ArityException.create(1, -1, arguments.length);
193197
}
194198
String name = checkString(arguments[0], "name of created value expected");
195199
if (arguments.length == 1) {
@@ -225,7 +229,9 @@ Object invokeMember(String member, Object[] arguments,
225229
@TruffleBoundary
226230
public MappedFunction execute(Object[] arguments) throws ArityException, UnsupportedTypeException {
227231
if (arguments.length == 0) {
228-
throw ArityException.create(1, 0);
232+
// FIXME: the maximum number of arguments is unbound.
233+
// Truffle currently uses -1 to handle an unbound number of arguments;
234+
throw ArityException.create(1, -1, 0);
229235
}
230236
Object function = arguments[0];
231237
if (!INTEROP.isExecutable(function)) {

projects/com.nvidia.grcuda/src/com/nvidia/grcuda/functions/map/MappedFunction.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ long execute(Object[] arguments,
236236
@Cached("createEqualityProfile()") PrimitiveValueProfile lengthProfile) throws ArityException {
237237
if (arguments.length != 3) {
238238
CompilerDirectives.transferToInterpreter();
239-
throw ArityException.create(3, arguments.length);
239+
throw ArityException.create(3, 3, arguments.length);
240240
}
241241
long size;
242242
try {
@@ -355,7 +355,7 @@ Object execute(Object[] arguments,
355355
@Cached("createEqualityProfile()") PrimitiveValueProfile lengthProfile) throws ArityException {
356356
if (arguments.length != 3) {
357357
CompilerDirectives.transferToInterpreter();
358-
throw ArityException.create(3, arguments.length);
358+
throw ArityException.create(3, 3, arguments.length);
359359
}
360360
int length = lengthProfile.profile(args.length);
361361
Object[] mappedArgs = new Object[length];
@@ -443,7 +443,7 @@ Object execute(Object[] arguments,
443443
@CachedLibrary(limit = "2") InteropLibrary memberInterop) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
444444
if (arguments.length != 3) {
445445
CompilerDirectives.transferToInterpreter();
446-
throw ArityException.create(3, arguments.length);
446+
throw ArityException.create(3, 3, arguments.length);
447447
}
448448
Object value = parentInterop.execute(parent, arguments);
449449
try {
@@ -503,7 +503,7 @@ Object execute(Object[] arguments,
503503
@CachedLibrary(limit = "2") InteropLibrary elementInterop) throws ArityException, UnsupportedTypeException, UnsupportedMessageException {
504504
if (arguments.length != 3) {
505505
CompilerDirectives.transferToInterpreter();
506-
throw ArityException.create(3, arguments.length);
506+
throw ArityException.create(3, 3, arguments.length);
507507
}
508508
Object value = parentInterop.execute(parent, arguments);
509509
try {
@@ -563,7 +563,7 @@ Object execute(Object[] arguments,
563563
@CachedLibrary("this.function") InteropLibrary mapInterop) throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
564564
if (arguments.length != 3) {
565565
CompilerDirectives.transferToInterpreter();
566-
throw ArityException.create(3, arguments.length);
566+
throw ArityException.create(3, 3, arguments.length);
567567
}
568568
Object value = parentInterop.execute(parent, arguments);
569569
try {
@@ -639,7 +639,7 @@ Object execute(Object[] arguments,
639639
@CachedLibrary("this.parent") InteropLibrary parentInterop) throws UnsupportedTypeException, ArityException, UnsupportedMessageException {
640640
if (arguments.length != 3) {
641641
CompilerDirectives.transferToInterpreter();
642-
throw ArityException.create(3, arguments.length);
642+
throw ArityException.create(3, 3, arguments.length);
643643
}
644644
return new ShreddedObject(parentInterop.execute(parent, arguments));
645645
}

0 commit comments

Comments
 (0)