diff --git a/llvm/tools/hpvm/test/unitTests/temp/3level.ll b/llvm/tools/hpvm/test/unitTests/temp/3level.ll new file mode 100644 index 0000000000000000000000000000000000000000..168e7b42322c8f7fa4be83a64cbd06d44dd9e428 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/3level.ll @@ -0,0 +1,116 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/3level.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%rtype = type <{i32, i32}> +%rtype_internal = type <{i32}> +%struct.arg = type <{ i32, %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.getNode() #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + call void @llvm.visc.init() + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + %2 = getelementptr %struct.arg* %in.addr, i32 0, i32 1 + %outputstruct = load %rtype* %2 + %output1 = extractvalue %rtype %outputstruct, 0 + %output2 = extractvalue %rtype %outputstruct, 1 + call void @llvm.visc.cleanup() + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output1) #0 + %call3 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output2) #0 + ret i32 0 +} + +define %rtype_internal @producer(i32 %id) { + %sum = add i32 4, %id + %output = insertvalue %rtype_internal undef, i32 %sum, 0 + ret %rtype_internal %output +} + +define %rtype_internal @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype_internal undef, i32 %sum, 0 + ret %rtype_internal %output +} + +define %rtype_internal @foo(i32 %id) { + %sum = add i32 15, %id + %output = insertvalue %rtype_internal undef, i32 %sum, 0 + ret %rtype_internal %output +} + +define %rtype_internal @subNode(i32 %id) { + %foo_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype_internal (i32)* @foo to i8*)) + call void @llvm.visc.bind.input(i8* %foo_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %foo_node, i32 0, i32 0) + ret %rtype_internal zeroinitializer +} + +define %rtype @Root(i32 %id) { + %p_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype_internal (i32)* @producer to i8*)) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype_internal (i32)* @consumer to i8*)) + %sub_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype_internal (i32)* @subNode to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %sub_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %sub_node, i32 0, i32 1) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/Makefile b/llvm/tools/hpvm/test/unitTests/temp/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..539ee5e8fbf010d33663c98470b245bb2710eeea --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/Makefile @@ -0,0 +1,13 @@ +PASSES := + +.PHONY: clean + +LLVM_INSTALL:=/home/psrivas2/Hetero/VISC/Code/trunk/llvm-install +LIBCLC:=/home/psrivas2/Hetero/VISC/Code/trunk/libclc +HOST:=gemm_opencl +KERNELS:=matrixMul +LLVM_CC:=$(LLVM_INSTALL)/bin/clang +LLVM_LINK:=$(LLVM_INSTALL)/bin/llvm-link + +clean : + rm -f DataflowGraph.dot* diff --git a/llvm/tools/hpvm/test/unitTests/temp/lit.local.cfg b/llvm/tools/hpvm/test/unitTests/temp/lit.local.cfg new file mode 100644 index 0000000000000000000000000000000000000000..c6106e4746f2d7da0600337ec7c03385d2460096 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.ll'] diff --git a/llvm/tools/hpvm/test/unitTests/temp/query2D.ll b/llvm/tools/hpvm/test/unitTests/temp/query2D.ll new file mode 100644 index 0000000000000000000000000000000000000000..c994c2a3ff5b166b2f192f4b900982b3b7afc508 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/query2D.ll @@ -0,0 +1,115 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/query2D.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%rtype = type <{i32}> +%struct.arg = type <{ i32, %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode1D(i8*, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode2D(i8*, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind +declare i8* @llvm.visc.getNode() #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.getParentNode(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumDims(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumNodeInstances.x(i8*) #0 + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + call void @llvm.visc.init() + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + %2 = getelementptr %struct.arg* %in.addr, i32 0, i32 1 + %outputstruct = load %rtype* %2 + %output = extractvalue %rtype %outputstruct, 0 + call void @llvm.visc.cleanup() + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output) #0 + ret i32 0 +} + +define %rtype @producer(i32 %id) { + %sum = add i32 4, %id + %this_node = call i8* @llvm.visc.getNode() + %dim = call i32 @llvm.visc.getNumNodeInstances.x(i8* %this_node) + %sum2 = add i32 %sum, %dim + %output = insertvalue %rtype undef, i32 %sum2, 0 + ret %rtype %output +} + +define %rtype @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root(i32 %dimension) { + %p_node = call i8* @llvm.visc.createNode2D(i8* bitcast (%rtype (i32)* @producer to i8*), i32 %dimension, i32 %dimension) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/query3D.ll b/llvm/tools/hpvm/test/unitTests/temp/query3D.ll new file mode 100644 index 0000000000000000000000000000000000000000..438fe60a3bc6c2dfe718da76d55041addc47367f --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/query3D.ll @@ -0,0 +1,121 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/query3D.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%rtype = type <{i32}> +%struct.arg = type <{ i32, %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode1D(i8*, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode2D(i8*, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode3D(i8*, i32, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind +declare i8* @llvm.visc.getNode() #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.getParentNode(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumDims(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumNodeInstances.x(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumNodeInstances.y(i8*) #0 + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + %2 = getelementptr %struct.arg* %in.addr, i32 0, i32 1 + %outputstruct = load %rtype* %2 + %output = extractvalue %rtype %outputstruct, 0 + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output) #0 + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rtype @producer(i32 %id) { + %sum = add i32 4, %id + %this_node = call i8* @llvm.visc.getNode() + %dim = call i32 @llvm.visc.getNumNodeInstances.y(i8* %this_node) + %sum2 = add i32 %sum, %dim + %output = insertvalue %rtype undef, i32 %sum2, 0 + ret %rtype %output +} + +define %rtype @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root(i32 %dimension) { + %p_node = call i8* @llvm.visc.createNode3D(i8* bitcast (%rtype (i32)* @producer to i8*), i32 %dimension, i32 10, i32 30) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/queryNodeInst.ll b/llvm/tools/hpvm/test/unitTests/temp/queryNodeInst.ll new file mode 100644 index 0000000000000000000000000000000000000000..24d6a3f0d30e6661c0f1396e082f889d54dc50be --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/queryNodeInst.ll @@ -0,0 +1,104 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/twoNode.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%rtype = type <{i32}> +%struct.arg = type <{ i32, %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind +declare i8* @llvm.visc.getNode() #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumDims(i8*) #0 + + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + %2 = getelementptr %struct.arg* %in.addr, i32 0, i32 1 + %outputstruct = load %rtype* %2 + %output = extractvalue %rtype %outputstruct, 0 + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output) #0 + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rtype @producer(i32 %id) { + %sum = add i32 4, %id + %this_node = call i8* @llvm.visc.getNode() + %numDim = call i32 @llvm.visc.getNumDims(i8* %this_node) + %sum2 = add i32 %sum, %numDim + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root(i32 %id) { + %p_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @producer to i8*)) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/queryNumDim.ll b/llvm/tools/hpvm/test/unitTests/temp/queryNumDim.ll new file mode 100644 index 0000000000000000000000000000000000000000..500e2ff41bd52f29a56cfd49563927bf6323482b --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/queryNumDim.ll @@ -0,0 +1,106 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/twoNode.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%rtype = type <{i32}> +%struct.arg = type <{ i32, %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.getNode() #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.getParentNode(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumDims(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + %2 = getelementptr %struct.arg* %in.addr, i32 0, i32 1 + %outputstruct = load %rtype* %2 + %output = extractvalue %rtype %outputstruct, 0 + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output) #0 + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rtype @producer(i32 %id) { + %sum = add i32 4, %id + %this_node = call i8* @llvm.visc.getNode() + %numDim = call i32 @llvm.visc.getNumDims(i8* %this_node) + %sum2 = add i32 %sum, %numDim + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root(i32 %id) { + %p_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @producer to i8*)) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/queryNumNodeInst.ll b/llvm/tools/hpvm/test/unitTests/temp/queryNumNodeInst.ll new file mode 100644 index 0000000000000000000000000000000000000000..48add92f16125bdf33c9691896a8b7259339fe78 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/queryNumNodeInst.ll @@ -0,0 +1,112 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/twoNode.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%rtype = type <{i32}> +%struct.arg = type <{ i32, %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode1D(i8*, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.getNode() #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.getParentNode(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumDims(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumNodeInstances.x(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + %2 = getelementptr %struct.arg* %in.addr, i32 0, i32 1 + %outputstruct = load %rtype* %2 + %output = extractvalue %rtype %outputstruct, 0 + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output) #0 + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rtype @producer(i32 %id) { + %sum = add i32 4, %id + %this_node = call i8* @llvm.visc.getNode() + %dim = call i32 @llvm.visc.getNumNodeInstances.x(i8* %this_node) + %sum2 = add i32 %sum, %dim + %output = insertvalue %rtype undef, i32 %sum2, 0 + ret %rtype %output +} + +define %rtype @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root(i32 %dimension) { + %p_node = call i8* @llvm.visc.createNode1D(i8* bitcast (%rtype (i32)* @producer to i8*), i32 %dimension) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/singleNode.ll b/llvm/tools/hpvm/test/unitTests/temp/singleNode.ll new file mode 100644 index 0000000000000000000000000000000000000000..20713e955fb457acec2e2968d1b4a2ae61396fe0 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/singleNode.ll @@ -0,0 +1,79 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/singleNode.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%rtype = type <{i32}> +%struct.arg = type <{ %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype ()* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rtype @foo() { + %sum = add i32 4, 10 + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root() { + %node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype ()* @foo to i8*)) + call void @llvm.visc.bind.output(i8* %node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/singleNodeStream.ll b/llvm/tools/hpvm/test/unitTests/temp/singleNodeStream.ll new file mode 100644 index 0000000000000000000000000000000000000000..fce75df6714240286e9a676e40e37c3f14e537a6 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/singleNodeStream.ll @@ -0,0 +1,118 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/twoNodeConnect.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" +%rptype = type <{i32*, i64}> +%struct.arg = type <{ i32*, i64, %rptype }> + +@in.str = private unnamed_addr constant [17 x i8] c"Input Value: %d\0A\00", align 1 +@out.str = private unnamed_addr constant [18 x i8] c"Output Value: %d\0A\00", align 1 +@hex.str = private unnamed_addr constant [19 x i8] c"Pointer Value: %d\0A\00", align 1 +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32, i1) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*, i1) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.push(i8*, i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.pop(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32, i1) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32, i1) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %num = alloca i32 + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([17 x i8]* @in.str, i64 0, i64 0), i32 %conv.i) #0 + %1 = bitcast %struct.arg* %in.addr to i32** + store i32 %conv.i, i32* %num + store i32* %num, i32** %1 + %args = bitcast %struct.arg* %in.addr to i8* + + ; Launch the pipeline + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rptype (i32*, i64)* @Root to i8*), i8* %args, i1 1) + + ; Push arguments into the pipeline + call void @llvm.visc.push(i8* %graphID, i8* %args) + call void @llvm.visc.push(i8* %graphID, i8* %args) + call void @llvm.visc.push(i8* %graphID, i8* %args) + call void @llvm.visc.push(i8* %graphID, i8* %args) + + ; Pop out arguments and read the output + %graph_output = call i8* @llvm.visc.pop(i8* %graphID) + %graph_output1 = call i8* @llvm.visc.pop(i8* %graphID) + %graph_output2 = call i8* @llvm.visc.pop(i8* %graphID) + %graph_output3 = call i8* @llvm.visc.pop(i8* %graphID) + %output.addr = bitcast i8* %graph_output to %rptype* + %outputstruct = load %rptype* %output.addr + %output = extractvalue %rptype %outputstruct, 0 + %output_val = load i32* %output + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @out.str, i64 0, i64 0), i32 %output_val) #0 + + call void @llvm.visc.wait(i8* %graphID) + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rptype @producer(i32* %id, i64 %size) { + %val = load i32* %id + ;%call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([17 x i8]* @in.str, i64 0, i64 0), i32 %val) #0 + %sum = add i32 2, %val + store i32 %sum, i32* %id + %temp = insertvalue %rptype undef, i32* %id, 0 + %output = insertvalue %rptype %temp, i64 %size, 1 + ret %rptype %output +} + +define %rptype @Root(i32* %id, i64 %size) { + %p_node = call i8* @llvm.visc.createNode(i8* bitcast (%rptype (i32*, i64)* @producer to i8*)) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0, i1 1) + call void @llvm.visc.bind.input(i8* %p_node, i32 1, i32 1, i1 1) + call void @llvm.visc.bind.output(i8* %p_node, i32 0, i32 0, i1 1) + call void @llvm.visc.bind.output(i8* %p_node, i32 1, i32 1, i1 1) + ret %rptype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/twoLaunch.ll b/llvm/tools/hpvm/test/unitTests/temp/twoLaunch.ll new file mode 100644 index 0000000000000000000000000000000000000000..48c973a7e6f1cc5422fffd8d9e4ae0a0e1a06bf9 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/twoLaunch.ll @@ -0,0 +1,96 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/singleNode.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%rtype = type <{i32}> +%struct.arg = type <{ %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr_1 = alloca %struct.arg + %in.addr_2= alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %args_1 = bitcast %struct.arg* %in.addr_1 to i8* + %args_2 = bitcast %struct.arg* %in.addr_2 to i8* + %graphID_1 = call i8* @llvm.visc.launch(i8* bitcast (%rtype ()* @Root_1 to i8*), i8* %args_1) + %graphID_2 = call i8* @llvm.visc.launch(i8* bitcast (%rtype ()* @Root_2 to i8*), i8* %args_2) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID_1) + call void @llvm.visc.wait(i8* %graphID_2) + call void @llvm.visc.cleanup() + + ret i32 0 +} + +define %rtype @foo_1() { + %sum = add i32 4, 10 + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @foo_2() { + %sum = add i32 4, 10 + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root_1() { + %node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype ()* @foo_1 to i8*)) + call void @llvm.visc.bind.output(i8* %node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +define %rtype @Root_2() { + %node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype ()* @foo_2 to i8*)) + call void @llvm.visc.bind.output(i8* %node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/twoNode.ll b/llvm/tools/hpvm/test/unitTests/temp/twoNode.ll new file mode 100644 index 0000000000000000000000000000000000000000..5e2899830b835ff50c9d2d8e4157451d4bd26f7f --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/twoNode.ll @@ -0,0 +1,88 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/twoNode.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" +%rtype = type <{i32}> +%struct.arg = type <{ %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rtype @producer() { + %sum = add i32 4, 10 + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root(i32 %id) { + %p_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype ()* @producer to i8*)) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/twoNodeConnect.ll b/llvm/tools/hpvm/test/unitTests/temp/twoNodeConnect.ll new file mode 100644 index 0000000000000000000000000000000000000000..06652b94e02c2cac66ab4a07e88dec0a04da49f8 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/twoNodeConnect.ll @@ -0,0 +1,93 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/twoNodeConnect.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" +%rtype = type <{i32}> +%struct.arg = type <{ i32, %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + %2 = getelementptr %struct.arg* %in.addr, i32 0, i32 1 + %outputstruct = load %rtype* %2 + %output = extractvalue %rtype %outputstruct, 0 + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output) #0 + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rtype @producer(i32 %id) { + %sum = add i32 4, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root(i32 %id) { + %p_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @producer to i8*)) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/twoNodeQuery.ll b/llvm/tools/hpvm/test/unitTests/temp/twoNodeQuery.ll new file mode 100644 index 0000000000000000000000000000000000000000..2e1ea0dba4659d92b9c1b0600732748c87571671 --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/twoNodeQuery.ll @@ -0,0 +1,105 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/twoNodeQuery.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" +%rtype = type <{i32}> +%struct.arg = type <{ i32, %rtype }> + +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32) + +; Function Attrs: nounwind +declare i8* @llvm.visc.getNode() #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.getParentNode(i8*) #0 + +; Function Attrs: nounwind +declare i32 @llvm.visc.getNumDims(i8*) #0 + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %1 = bitcast %struct.arg* %in.addr to i32* + store i32 %conv.i, i32* %1 + %args = bitcast %struct.arg* %in.addr to i8* + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rtype (i32)* @Root to i8*), i8* %args) + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %conv.i) #0 + call void @llvm.visc.wait(i8* %graphID) + %2 = getelementptr %struct.arg* %in.addr, i32 0, i32 1 + %outputstruct = load %rtype* %2 + %output = extractvalue %rtype %outputstruct, 0 + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %output) #0 + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rtype @producer(i32 %id) { + %sum = add i32 4, %id + %this_node = call i8* @llvm.visc.getNode() + %numDim = call i32 @llvm.visc.getNumDims(i8* %this_node) + %sum2 = add i32 %sum, %numDim + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @consumer(i32 %id) { + %sum = add i32 10, %id + %output = insertvalue %rtype undef, i32 %sum, 0 + ret %rtype %output +} + +define %rtype @Root(i32 %id) { + %p_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @producer to i8*)) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rtype (i32)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0) + ret %rtype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/llvm/tools/hpvm/test/unitTests/temp/twoNodeStream.ll b/llvm/tools/hpvm/test/unitTests/temp/twoNodeStream.ll new file mode 100644 index 0000000000000000000000000000000000000000..6e9925951884775e7ba60bb396a97fd9bc0ef52d --- /dev/null +++ b/llvm/tools/hpvm/test/unitTests/temp/twoNodeStream.ll @@ -0,0 +1,123 @@ +; RUN: opt -load LLVMBuildDFG.so -load LLVMDFG2LLVM_X86.so -load LLVMClearDFG.so -dfg2llvm-x86 -clearDFG -o %t.ll -S < %s +; RUN: llvm-link %t.ll ~/current-src/projects/visc-rt/visc-rt.ll -S -o %t.linked.ll +; RUN: clang++ -O3 %t.linked.ll -lpthread -lOpenCL -lrt -o %t.bin +; RUN: %t.bin 5 +; ModuleID = '/home/psrivas2/current-test/unitTests/twoNodeConnect.ll' +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" +%rptype = type <{i32*, i64}> +%rctype = type <{i32*, i64}> +%struct.arg = type <{ i32*, i64, %rctype }> + +@in.str = private unnamed_addr constant [17 x i8] c"Input Value: %d\0A\00", align 1 +@out.str = private unnamed_addr constant [18 x i8] c"Output Value: %d\0A\00", align 1 +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind +declare void @llvm.visc.init() #1 + +; Function Attrs: nounwind +declare void @llvm.visc.cleanup() #1 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createNode(i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.createEdge(i8*, i8*, i1, i32, i32, i1) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.launch(i8*, i8*, i1) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.push(i8*, i8*) #0 + +; Function Attrs: nounwind +declare i8* @llvm.visc.pop(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.wait(i8*) #0 + +; Function Attrs: nounwind +declare void @llvm.visc.bind.input(i8*, i32, i32, i1) + +; Function Attrs: nounwind +declare void @llvm.visc.bind.output(i8*, i32, i32, i1) + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture %argv) #1 { +entry: + call void @llvm.visc.init() + %in.addr = alloca %struct.arg + %num = alloca i32 + %arrayidx = getelementptr inbounds i8** %argv, i64 1 + %0 = load i8** %arrayidx, align 8, !tbaa !0 + %call.i = tail call i64 @strtol(i8* nocapture %0, i8** null, i32 10) #0 + %conv.i = trunc i64 %call.i to i32 + %call1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([17 x i8]* @in.str, i64 0, i64 0), i32 %conv.i) #0 + %1 = bitcast %struct.arg* %in.addr to i32** + store i32 %conv.i, i32* %num + store i32* %num, i32** %1 + %args = bitcast %struct.arg* %in.addr to i8* + + ; Launch the pipeline + %graphID = call i8* @llvm.visc.launch(i8* bitcast (%rctype (i32*, i64)* @Root to i8*), i8* %args, i1 1) + + ; Push arguments into the pipeline + call void @llvm.visc.push(i8* %graphID, i8* %args) + + ; Pop out arguments and read the output + %graph_output = call i8* @llvm.visc.pop(i8* %graphID) + %output.addr = bitcast i8* %graph_output to %rctype* + %outputstruct = load %rctype* %output.addr + %output = extractvalue %rctype %outputstruct, 0 + %output_val = load i32* %output + %call2 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @out.str, i64 0, i64 0), i32 %output_val) #0 + + call void @llvm.visc.wait(i8* %graphID) + call void @llvm.visc.cleanup() + ret i32 0 +} + +define %rptype @producer(i32* %id, i64 %size) { + %val = load i32* %id + %sum = add i32 2, %val + store i32 %sum, i32* %id + %temp = insertvalue %rptype undef, i32* %id, 0 + %output = insertvalue %rptype %temp, i64 %size, 1 + ret %rptype %output +} + +define %rctype @consumer(i32* %id, i64 %size) { + %val = load i32* %id + %sum = add i32 3, %val + store i32 %sum, i32* %id + %temp = insertvalue %rctype undef, i32* %id, 0 + %output = insertvalue %rctype %temp, i64 %size, 1 + ret %rctype %output +} + +define %rctype @Root(i32* %id, i64 %size) { + %p_node = call i8* @llvm.visc.createNode(i8* bitcast (%rptype (i32*, i64)* @producer to i8*)) + %c_node = call i8* @llvm.visc.createNode(i8* bitcast (%rctype (i32*, i64)* @consumer to i8*)) + %edge = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 0, i32 0, i1 1) + %edge2 = call i8* @llvm.visc.createEdge(i8* %p_node, i8* %c_node, i1 false, i32 1, i32 1, i1 1) + call void @llvm.visc.bind.input(i8* %p_node, i32 0, i32 0, i1 1) + call void @llvm.visc.bind.input(i8* %p_node, i32 1, i32 1, i1 0) + call void @llvm.visc.bind.output(i8* %c_node, i32 0, i32 0, i1 1) + call void @llvm.visc.bind.output(i8* %c_node, i32 1, i32 1, i1 1) + ret %rctype zeroinitializer +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture, ...) #2 + +; Function Attrs: nounwind +declare i64 @strtol(i8*, i8** nocapture, i32) #2 + +attributes #0 = { nounwind } +attributes #1 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #2 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" } + +!0 = metadata !{metadata !"any pointer", metadata !1} +!1 = metadata !{metadata !"omnipotent char", metadata !2} +!2 = metadata !{metadata !"Simple C/C++ TBAA"}