Off load computational stuff? #70
Replies: 3 comments 7 replies
-
|
Thank you for trying TornadoVM. TornadoVM is mainly designed for Array Programming (https://en.wikipedia.org/wiki/Array_programming) and inputs/outputs are passed as parameters to the expressions to be offloaded. TornadoVM currently cannot return a value from a sequential expression. Additionally, we cannot use wrappers. Instead, you can use an array So I tuned the code as follows (note that you are running only with 1 thread on the accelerator): import uk.ac.manchester.tornado.api.TaskSchedule;
public class Foo {
public static void polySine(final double x, double[] result) {
double x2 = x*x;
double p = 2.7553817452272217E-6;
p = p * x2 + -1.9841269659586505E-4;
p = p * x2 + 0.008333333333329196;
p = p * x2 + -0.16666666666666666;
p = p * x2 * x;
result[0] = p;
}
public static void polySineTvm(final double x, double[] result) {
final TaskSchedule t0 = new TaskSchedule("s0")
.task("t0", Foo::polySine, x, result)
.streamOut(result);
t0.execute();
}
public static void main(String[] args) {
double[] r = new double[1];
polySineTvm(2.2132, r);
}
}I executed this program, and you will end up with something like this. TornadoVM compiler use GraalJIT for specializing the code. So we end-up with the following code: $ tornado --debug --printKernel Foo
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
__kernel void polySine(__global uchar *_heap_base, ulong _frame_base, __constant uchar *_constant_region, __local uchar *_local_region, __global int *_atomics)
{
ulong ul_0, ul_1;
__global ulong *_frame = (__global ulong *) &_heap_base[_frame_base];
// BLOCK 0
ul_0 = (ulong) _frame[4];
ul_1 = ul_0 + 24L;
*((__global double *) ul_1) = -1.4123909221508955;
return;
} // kernel
Task info: s0.t0
Backend : OpenCL
Device : GeForce GTX 1050 CL_DEVICE_TYPE_GPU (available)
Dims : 0
Global work offset: [0]
Global work size : [1]
Local work size : [1, 1, 1]
Number of workgroups : [1]Let us know if you have more questions. |
Beta Was this translation helpful? Give feedback.
-
|
#67 |
Beta Was this translation helpful? Give feedback.
-
|
what do you think about creating an fpga aws image where everything works.. what do you think? thx |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to learn tornado vm..
So for example i am trying to wrap a computational method..
When I execute the tvm version I am getting the following error:
Am I misunderstanding the use case for using tvm?
Thank You!
Beta Was this translation helpful? Give feedback.
All reactions