Przeglądaj źródła

tests: move fpga application to dedicated directory

Nathalie Furmento 4 lat temu
rodzic
commit
7ee28b6066

+ 8 - 8
tests/Makefile.am

@@ -385,14 +385,14 @@ myPROGRAMS +=				\
 
 if STARPU_USE_FPGA
 myPROGRAMS +=				\
-        perfmodels/max_fpga
+        fpga/max_fpga
 endif
 endif
 
 if STARPU_USE_FPGA
-myPROGRAMS +=					\
-	perfmodels/max_fpga			\
-	perfmodels/max_riffa
+myPROGRAMS +=				\
+	fpga/max_fpga			\
+	fpga/max_riffa
 endif
 
 MICROBENCHS = \
@@ -1062,10 +1062,10 @@ perfmodels_regression_based_energy_SOURCES=\
 perfmodels_regression_based_gpu_SOURCES=\
 	perfmodels/regression_based_gpu.c
 
-perfmodels_max_fpga_SOURCES=\
-	perfmodels/max_fpga.c
-perfmodels_max_fpga_LDADD = $(LDADD) \
-	$(srcdir)/perfmodels/slic_StreamFMA.o
+fpga_max_fpga_SOURCES=\
+	fpga/max_fpga.c
+fpga_max_fpga_LDADD = $(LDADD) \
+	$(srcdir)/fpga/slic_StreamFMA.o
 
 if STARPU_USE_OPENCL
 perfmodels_regression_based_memset_SOURCES+=\

tests/perfmodels/LMemLoopbackCpuCode.c → tests/fpga/LMemLoopbackCpuCode.c


+ 60 - 0
tests/fpga/StreamFMACpuCode.cpp

@@ -0,0 +1,60 @@
+#include <cmath>
+#include <algorithm>
+#include <iostream>
+#include <vector>
+#include <random>
+
+#include "StreamFMA.h"
+#include "MaxSLiCInterface.h"
+
+int main()
+{
+	const int size = 400;
+	int sizeBytes = size * sizeof(int32_t);
+	int32_t *a = (int32_t*) malloc(sizeBytes);
+	int32_t *b = (int32_t*) malloc(sizeBytes);
+	int32_t *c = (int32_t*) malloc(sizeBytes);
+
+	// TODO Generate input data
+	for(int i = 0; i < size; ++i)
+	{
+		a[i] = random() % 100;
+		b[i] = random() % 100;
+	}
+	max_file_t *maxfile = StreamFMA_init();
+	max_engine_t *engine = max_load(maxfile, "*");
+
+	max_actions_t* act = max_actions_init(maxfile, NULL);
+
+	max_set_ticks  (act, "StreamFMAKernel", size);
+	max_queue_input(act, "a", a, size * sizeof(int32_t));
+	max_queue_input(act, "b", b, size * sizeof(int32_t));
+	max_queue_output(act, "output", c, size * sizeof(int32_t));
+	max_run(engine, act);
+
+	max_actions_free(act);
+	max_unload(engine);
+
+	int ret = 0;
+	// TODO Use result data
+	for(std::size_t i = 0; i < size; ++i)
+	{
+		int32_t ref =a[i] + b[i];
+		if (c[i] != ref)
+		{
+			std::cout << "Invalid Output at index " << i << ": " << std::endl;
+			std::cout << " reference: " << ref << std::endl;
+			std::cout << " value:     " << c[i] << std::endl;
+			ret = 1;
+			break;
+		}
+	}
+
+	if(0 == ret)
+	{
+		std::cout << "All " << size << " values calculated correctly on the DFE!" << std::endl;
+	}
+
+	std::cout << "Done." << std::endl;
+	return ret;
+}

+ 8 - 10
tests/perfmodels/StreamFMAKernel.maxj

@@ -1,21 +1,22 @@
-package perfmodels;
+package fpga;
 
 import com.maxeler.maxcompiler.v2.kernelcompiler.Kernel;
 import com.maxeler.maxcompiler.v2.kernelcompiler.KernelParameters;
 import com.maxeler.maxcompiler.v2.kernelcompiler.types.base.DFEType;
 import com.maxeler.maxcompiler.v2.kernelcompiler.types.base.DFEVar;
 
-class StreamFMAKernel extends Kernel {
-
+class StreamFMAKernel extends Kernel
+{
 	private static final DFEType type = dfeInt(32);
 
-	protected StreamFMAKernel(KernelParameters parameters) {
+	protected StreamFMAKernel(KernelParameters parameters)
+	{
 		super(parameters);
-                
+
                 DFEVar inAT1 = io.input("inAT1", type);
                 DFEVar inBT1 = io.input("inBT1", type);
                 DFEVar oDataT1;
-                
+
                 DFEVar inAT2 = io.input("inAT2", type);
                 DFEVar inBT2 = io.input("inBT2", type);
                 DFEVar oDataT2;
@@ -23,7 +24,7 @@ class StreamFMAKernel extends Kernel {
                 DFEVar inAT3 = io.input("inAT3", type);
                 DFEVar inBT3 = io.input("inBT3", type);
                 DFEVar oDataT3;
-               
+
                 oDataT1 = inAT1+inBT1;
                 oDataT2 = inAT2*inBT2;
                 oDataT3 = inAT3+inBT3;
@@ -31,8 +32,5 @@ class StreamFMAKernel extends Kernel {
                 io.output("oDataT1", oDataT1, type);
                 io.output("oDataT2", oDataT2, type);
                 io.output("oDataT3", oDataT3, type);
-           
 	}
-
 }
-

+ 12 - 15
tests/perfmodels/StreamFMAManager.maxj

@@ -1,4 +1,4 @@
-package perfmodels;
+package fpga;
 
 import com.maxeler.maxcompiler.v2.build.EngineParameters;
 //import com.maxeler.maxcompiler.v2.kernelcompiler.Kernel;
@@ -12,12 +12,13 @@ import com.maxeler.maxcompiler.v2.managers.custom.stdlib.LMemInterface;
 //import com.maxeler.maxcompiler.v2.managers.engine_interfaces.InterfaceParam;
 import com.maxeler.platform.max5.manager.MAX5CManager;
 
-public class StreamFMAManager extends MAX5CManager {
-
+public class StreamFMAManager extends MAX5CManager
+{
         //private static final CPUTypes TYPE = CPUTypes.INT32;
         private static final String kernel_name = "StreamFMAKernel";
 
-        public StreamFMAManager(EngineParameters params) {
+        public StreamFMAManager(EngineParameters params)
+	{
                 super(params);
                 KernelBlock kernel = addKernel(new StreamFMAKernel(makeKernelParameters(kernel_name)));
 
@@ -25,7 +26,7 @@ public class StreamFMAManager extends MAX5CManager {
 
                 kernel.getInput("inAT1") <== addStreamFromCPU("inAT1");
                 kernel.getInput("inBT1") <== addStreamFromCPU("inBT1");
-               
+
                 //addStreamToCPU("oDataT1") <== kernel.getOutput("oDataT1");
 
                 DFELink inAT2 = iface.addStreamFromLMem("inAT2", LMemCommandGroup.MemoryAccessPattern.LINEAR_1D);
@@ -42,24 +43,20 @@ public class StreamFMAManager extends MAX5CManager {
 
                 DFELink oDataT1 = iface.addStreamToLMem("oDataT1", LMemCommandGroup.MemoryAccessPattern.LINEAR_1D);
                 oDataT1 <== kernel.getOutput("oDataT1");
-                
+
                 DFELink oDataT2 = iface.addStreamToLMem("oDataT2", LMemCommandGroup.MemoryAccessPattern.LINEAR_1D);
-                oDataT2 <== kernel.getOutput("oDataT2");  
+                oDataT2 <== kernel.getOutput("oDataT2");
 
                 //DFELink oDataT3 = iface.addStreamToLMem("oDataT3", LMemCommandGroup.MemoryAccessPattern.LINEAR_1D);
                 //oDataT3 <== kernel.getOutput("oDataT3");
-    
+
                 addStreamToCPU("oDataT3") <== kernel.getOutput("oDataT3");
-               
         }
 
-
-
-        public static void main(String[] args) {
+        public static void main(String[] args)
+	{
                 StreamFMAManager manager = new StreamFMAManager(new EngineParameters(args));
-               
+
                 manager.build();
         }
-
-                       
 }

+ 1 - 3
tests/perfmodels/max_fpga.c

@@ -23,7 +23,6 @@
 #include "MaxSLiCInterface.h"
 #define SIZE (192/sizeof(int32_t))
 
-
 void fpga_impl(void *buffers[], void *cl_arg)
 {
 	(void)cl_arg;
@@ -82,12 +81,11 @@ void fpga_impl(void *buffers[], void *cl_arg)
 	printf("T3 finished\n");
 
 	printf("Running DFE.\n");
-
 }
 
 static struct starpu_codelet cl =
 {
- 	.fpga_funcs = {fpga_impl},
+	.fpga_funcs = {fpga_impl},
 	.nbuffers = 3,
 	.modes = {STARPU_R, STARPU_R, STARPU_W}
 };

+ 0 - 61
tests/perfmodels/StreamFMACpuCode.cpp

@@ -1,61 +0,0 @@
-#include <cmath>
-#include <algorithm>
-#include <iostream>
-#include <vector>
-#include <random>
-
-#include "StreamFMA.h"
-#include "MaxSLiCInterface.h"
-
-int main()
-{
-    const int size = 400;
-    int sizeBytes = size * sizeof(int32_t);
-    int32_t *a = (int32_t*) malloc(sizeBytes);
-    int32_t *b = (int32_t*) malloc(sizeBytes);
-    int32_t *c = (int32_t*) malloc(sizeBytes);
-    
-    // TODO Generate input data
-    for(int i = 0; i < size; ++i)
-        {
-         a[i] = random() % 100;
-         b[i] = random() % 100;
-              }
-    max_file_t *maxfile = StreamFMA_init();
-    max_engine_t *engine = max_load(maxfile, "*");
-
-    max_actions_t* act = max_actions_init(maxfile, NULL);
-
-    max_set_ticks  (act, "StreamFMAKernel", size);
-    max_queue_input(act, "a", a, size * sizeof(int32_t));
-    max_queue_input(act, "b", b, size * sizeof(int32_t));
-    max_queue_output(act, "output", c, size * sizeof(int32_t));
-    max_run(engine, act);
-
-    max_actions_free(act);
-    max_unload(engine);
-
-
-    int ret = 0;
-    // TODO Use result data
-    for(std::size_t i = 0; i < size; ++i)
-    {
-        int32_t ref =a[i] + b[i];
-        if (c[i] != ref)
-        {
-            std::cout << "Invalid Output at index " << i << ": " << std::endl;
-            std::cout << " reference: " << ref << std::endl;
-            std::cout << " value:     " << c[i] << std::endl;
-            ret = 1;
-            break;
-        }
-    }
-
-    if(0 == ret)
-    {
-        std::cout << "All " << size << " values calculated correctly on the DFE!" << std::endl;
-    }
-
-    std::cout << "Done." << std::endl;
-    return ret;
-}