Guys, I had to try building and running the Sumatra/Java8 stack - this claims to be able to JIT Java8 closures into HSAIL (from memory: Heterogeneous Architecture Independent Language), which can then either be run on an HSAIL emulator (in this case Okra) or, if you have HSA enabled h/w (which is not expensive), compiled by a "finalizer" onto a target GPGPU on chip with your CPU and sharing the same memory model. We are talking about e.g. 512 cores running at about 25% of the speed of your CPU cores (AMD's A10 7850K). Sound like fun ?
I followed the instructions here: https://wiki.openjdk.java.net/display/Sumatra/Sumatra+JDK+build+instructions Of course, then I thought I should see whether I could get a simple piece of Clojure to run on the emulator. You will need to read up a bit on Graal to follow this fully - all it does is to copy the contents of an input array into an output array - but the ramifications of its working are substantial: (ns seqspert.core (:import [com.oracle.graal.hsail HSAIL] [com.oracle.graal.hotspot HotSpotGraalRuntime] [com.oracle.graal.hotspot.hsail HSAILHotSpotBackend] [com.amd.okra OkraContext OkraKernel] )) ;;------------------------------------------------------------------------------ (set! *warn-on-reflection* true) ;;------------------------------------------------------------------------------ (definterface Kernel (^void invoke [^int i])) (defn ^String hsa-compile [^Kernel kernel] (let [method (.getDeclaredMethod (class kernel) "invoke" (into-array ^Class [(Integer/TYPE)])) ^HSAILHotSpotBackend backend (.getBackend (HotSpotGraalRuntime/runtime) HSAIL) resolved (.lookupJavaMethod (.getMetaAccess (.getProviders backend)) method)] (.getCodeString (.compileKernel backend resolved false)))) (defn ^OkraKernel apply-int-kernel [kernel i & args] (let [^OkraContext context (OkraContext.)] (doto (OkraKernel. (doto context (.setVerbose true)) (hsa-compile kernel) "&run") (.setLaunchAttributes (int i)) (.dispatchWithArgs (into-array Object (conj args kernel)))) (.dispose context))) (let [n 32 in (int-array (range n)) out (int-array n)] (println "INPUT: " (into [] in)) (println "BEFORE:" (into [] out)) (apply-int-kernel (reify Kernel (^void invoke [^Kernel self ^int i] (aset out i (aget in i)))) n) (println "AFTER: " (into [] out))) and here is the output: INPUT: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31] BEFORE: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] Fixed Hsail is ============== version 0:95: $full : $large; // instance method HotSpotMethod<core$eval1195$reify__1196.invoke(int)> kernel &run ( align 8 kernarg_u64 %_this ) { ld_kernarg_u64 $d0, [%_this]; workitemabsid_u32 $s0, 0; @L0: ld_global_u32 $d1, [$d0 + 16]; cmp_eq_b1_u64 $c0, $d1, 0; // null test cbr $c0, @L1; @L2: ld_global_u32 $d0, [$d0 + 20]; cmp_eq_b1_u64 $c0, $d0, 0; // null test cbr $c0, @L3; @L4: mov_b64 $d2, 0x100000b08; cmp_eq_b1_u64 $c0, $d0, 0; // null test cbr $c0, @L5; @L6: ld_global_u32 $d3, [$d0 + 8]; shl_u64 $d3, $d3, 3; cmp_eq_b1_s64 $c0, $d3, $d2; cbr $c0, @L7; @L8: mov_b32 $s1, 0; @L9: cmp_eq_b1_u64 $c0, $d0, 0; // null test cbr $c0, @L14; @L11: cmp_ne_b1_s32 $c0, $s1, 1; cbr $c0, @L32; @L14: ld_global_s32 $s1, [$d0 + 12]; cmp_ge_b1_u32 $c0, $s0, $s1; cbr $c0, @L31; @L15: cmp_eq_b1_u64 $c0, $d1, 0; // null test cbr $c0, @L16; @L17: ld_global_u32 $d3, [$d1 + 8]; shl_u64 $d3, $d3, 3; cmp_eq_b1_s64 $c0, $d3, $d2; cbr $c0, @L18; @L19: mov_b32 $s1, 0; @L20: cmp_eq_b1_u64 $c0, $d1, 0; // null test cbr $c0, @L25; @L22: cmp_ne_b1_s32 $c0, $s1, 1; cbr $c0, @L30; @L25: ld_global_s32 $s1, [$d1 + 12]; cmp_ge_b1_u32 $c0, $s0, $s1; cbr $c0, @L29; @L26: ld_global_s32 $s1, [$d1 + 12]; cmp_ge_b1_u32 $c0, $s0, $s1; cbr $c0, @L28; @L27: cvt_s64_s32 $d2, $s0; mul_s64 $d2, $d2, 4; add_u64 $d0, $d0, $d2; ld_global_s32 $s1, [$d0 + 16]; cvt_s64_s32 $d0, $s0; mul_s64 $d0, $d0, 4; add_u64 $d1, $d1, $d0; st_global_s32 $s1, [$d1 + 16]; ret; @L7: mov_b32 $s1, 1; brn @L9; @L18: mov_b32 $s1, 1; brn @L20; @L5: mov_b32 $s1, 0; brn @L9; @L16: mov_b32 $s1, 0; brn @L20; @L1: mov_b32 $s0, -11; @L33: ret; @L31: mov_b32 $s0, -27; brn @L33; @L32: mov_b32 $s0, -35; brn @L33; @L3: mov_b32 $s0, -11; brn @L33; @L28: mov_b32 $s0, -27; brn @L33; @L30: mov_b32 $s0, -35; brn @L33; @L29: mov_b32 $s0, -92; brn @L33; }; spawning Program: hsailasm temp_hsa.hsail -g -o temp_hsa.o hsailasm succeeded createProgram succeeded createKernel succeeded level 0, grid=32, group=1 pushPointerArg, addr=0 setPointerArg, addr=0xf5529930 AFTER: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31] I tried doing a little maths on the value on the way through, but that did not work :-( Too tired to say much more now - but will pick this up tomorrow and play some more. Please let me know if you are interested - I will start checking in code somewhere. Jules -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.