Presenter. MaxAcademy Lecture Series – V1.0, September 2011. Dataflow Programming with MaxCompiler. Lecture Overview. Programming FPGAs MaxCompiler Streaming Kernels Compile and build Java metaprogramming. Reconfigurable Computing with FPGAs. DSP Block. IO Block.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Presenter
MaxAcademy Lecture Series – V1.0, September 2011
Dataflow Programming with MaxCompiler
DSP Block
IO Block
Logic Cell (105 elements)
Block RAM (20TB/s)
Block RAM
DSP Block
MaxRack
10U, 20U or 40U
MaxCard
MaxNode
MaxRack
1U server
4 MAX3 Cards
Intel Xeon CPUs
PCIExpress Gen 2
Typical 50W80W
2448GB RAM
10U, 20U or 40U Rack
DSL
DSL
DSL
DSL
Higher Level Libraries
Level of Abstraction
Higher Level Libraries
Flexible Compiler System: MaxCompiler
Possible applications
Original Application
Identify code for acceleration and analyze bottlenecks
Transform app, architect and model performance
Write MaxCompiler code
Integrate with Host code
Simulate
Start
NO
NO
Functions correctly?
Meets performance goals?
Accelerated Application
Build for Hardware
YES
YES
class MyAccelerator extends Kernel {
public MyAccelerator(…) {
HWVarx = io.input("x", hwFloat(8, 24));
HWVar y = io.input(“y", hwFloat(8, 24));
HWVar x2 = x * x;
HWVar y2 = y * y;
HWVar result = x2 + y2 + 30;
io.output(“z", result, hwFloat(8, 24));
}
}
+
+
*
Memory
Host application
CPU
MaxCompilerRT
MaxelerOS
Kernels
FPGA
PCI Express
Memory
Manager
Computationally intensive components
Main
Memory
CPU
Host
Code
Host Code (.c)
for (int i =0; i < DATA_SIZE; i++)
y[i]= x[i] * x[i] + 30;
int*x, *y;
Main
Memory
Memory
x
CPU
Host
Code
x
FPGA
Manager
30
MaxCompilerRT
MaxelerOS
PCI
Express
+
y
x
y
Manager (.java)
Host Code (.c)
MyKernel (.java)
link(“y", PCIE));
Manager m = new Manager();
Kernel k =
new MyKernel();
m.setKernel(k);
m.setIO(
link(“x", PCIE),
m.build();
int*x, *y;
for (int i =0; i < DATA_SIZE; i++)
y[i]= x[i] * x[i] + 30;
device = max_open_device(maxfile,
"/dev/maxeler0");
max_run(device,
max_input("x", x, DATA_SIZE*4),
max_runfor("Kernel", DATA_SIZE));
max_output("y", y, DATA_SIZE*4),
HWVarx = io.input("x", hwInt(32));
HWVarresult = x * x + 30;
io.output("y", result, hwInt(32));
Main
Memory
Memory
x
CPU
y
Host
Code
x
FPGA
Manager
30
MaxCompilerRT
MaxelerOS
PCI
Express
+
x
y
Manager (.java)
Host Code (.c)
MyKernel (.java)
Manager m = new Manager();
Kernel k =
new MyKernel();
m.setKernel(k);
m.setIO(
link(“x", PCIE),
m.build();
device = max_open_device(maxfile,
"/dev/maxeler0");
int*x, *y;
device = max_open_device(maxfile,
"/dev/maxeler0");
max_run(device,
max_input("x", x, DATA_SIZE*4),
max_runfor("Kernel", DATA_SIZE));
HWVarx = io.input("x", hwInt(32));
HWVarresult = x * x + 30;
io.output("y", result, hwInt(32));
link(“y", DRAM_LINEAR1D));
x
public class MyKernelextends Kernel {
publicMyKernel (KernelParameters parameters) {
super(parameters);
HWVar x = io.input("x", hwInt(32));
HWVar result = x * x + 30;
io.output("y", result, hwInt(32));
}
}
x
30
+
y
x
x
5 4 3 2 1 0
30
30
+
0
y
0
30
x
x
5 4 3 2 1 0
30 31
30
+
1
y
1
31
x
x
5 4 3 2 1 0
30 31 34
30
+
2
y
4
34
x
x
5 4 3 2 1 0
30 31 34 39
30
+
3
y
9
39
x
x
5 4 3 2 1 0
30 31 34 39 46
30
+
4
y
16
46
x
x
5 4 3 2 1 0
30 31 34 39 46 55
30
+
5
y
25
55
x
What dataflow graph is generated?
HWVar x = io.input(“x”, type);
HWVar y;
y = x + 1;
io.output(“y”, y, type);
1
+
y
x
What dataflow graph is generated?
HWVar x = io.input(“x”, type);
HWVar y;
y = x + x + x;
io.output(“y”, y, type);
+
+
y
What’s the value of h if we stream in 1?
HWVar h = io.input(“h”, type);
int s = 2;
s = s + 5
h = h + 10
h = h + s;
1
10
+
7
+
18
What’s the value of s if we stream in 1?
HWVar h = io.input(“h”, type);
int s = 2;
s = s + 5
h = h + 10
s = h + s;
Compile error.
You can’t assign a hardware value to a Java int
x
What dataflow graph is generated?
HWVar x = io.input(“x”, type);
int s = 10;
HWVar y;
if (s < 100) { y = x + 1; }
else { y = x – 1; }
io.output(“y”, y, type);
1
+
y
What dataflow graph is generated?
HWVar x = io.input(“x”, type);
HWVar y;
if (x < 10) { y = x + 1; }
else { y = x – 1; }
io.output(“y”, y, type);
Compile error.
You can’t use the value of ‘x’ in a Java conditional
Ternaryif operator is overloaded
x
HWVar x = io.input(“x”, type);
HWVar y;
y = (x > 10) ? x + 1 : x – 1
io.output(“y”, y, type);
10
1
1

>
+
y
What dataflow graph is generated?
HWVar x = io.input(“x”, type);
HWVar y = x;
for (inti = 1; i <= 3; i++) {
y = y + i;
}
io.output(“y”, y, type);
x
1
+
2
+
3
+
Can make the loop any size – until you run out of space on the chip!
Larger loops can be partially unrolled in space and used multiple times in time – see Lecture on loops and cyclic graphs
y
Real data flow graph as
generated by MaxCompiler
4866 nodes;10,000s of stages/cycles
for (inti = 0; i < 6; i++) {
HWVar x = io.input(“x”+i, hwInt(32));
HWVar y = x;
if (i % 3 != 0) {
for (int j = 0; j < 3; j++) {
y = y + x*j;
}
} else {
y = y * y;
}
io.output(“y”+i, y, hwInt(32));
}