tests: Add example of using KVM acceleration with an app
authorDavid Hashe <david.j.hashe@gmail.com>
Mon, 22 Aug 2016 15:41:37 +0000 (11:41 -0400)
committerDavid Hashe <david.j.hashe@gmail.com>
Mon, 22 Aug 2016 15:41:37 +0000 (11:41 -0400)
Add #ifdef's to gpu-hello.cpp demonstrating how to annotate an application
for KVM acceleration.

tests/test-progs/gpu-hello/src/gpu-hello.cpp

index b054558f5bab50beb0e8d18543364a24df668347..bdff074a8cad33486aac2827e8dc0fa4199c1555 100755 (executable)
 #include <fstream>
 #include <string>
 
+#ifdef KVM_SWITCH
+#include "m5op.h"
+
+void *m5_mem = (void*)0xffffc90000000000;
+#endif
+
 #define SUCCESS 0
 #define FAILURE 1
 
@@ -247,6 +253,10 @@ runCLKernel(cl_kernel kernel)
         return FAILURE;
     }
 
+#ifdef KVM_SWITCH
+    m5_switchcpu();
+#endif
+
     // 2. Launch kernel
     status = clEnqueueNDRangeKernel(commandQueue, kernel, 1, NULL,
                                     globalThreads, localThreads, 0, NULL,