Error with nvvmCompileProgram in The JIT
Hi:  I generate IR by LLVM, and need compile the IR into the PTX, but, I get this error: nvvmCompileProgram: Failed test (2, 0): parse expected top-level entity thanks for any reply. this is my IR file: ; ModuleID = 'test' source_filename = "test" 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-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64" target triple = "nvptx64-nvidia-cuda" ; Function Attrs: nounwind readnone declare i32 @llvm.nvvm.read.ptx.sreg.tid.x() #0 ; Function Attrs: nounwind readnone declare i32 @llvm.nvvm.read.ptx.sreg.ntid.x() #0 ; Function Attrs: nounwind readnone declare i32 @llvm.nvvm.read.ptx.sreg.ctaid() #0 ; Function Attrs: inlinehint define i32 @getThreadID() #1 { get_thread_id_entry: %0 = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x() %1 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid() %2 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x() %3 = mul i32 %0, %1 %4 = add i32 %2, %3 ret i32 %4 } define void @kernel(double* %src, double* %dst, i32 %length) { entry: %0 = call i32 @getThreadID() %1 = icmp slt i32 %0, %length br i1 %1, label %LoopBB, label %EndBB LoopBB: ; preds = %entry %2 = sext i32 %0 to i64 %src_ptr = getelementptr double, double* %src, i64 %2 %src_val = load double, double* %src_ptr, align 8 %3 = fcmp ult double %src_val, 2.000000e+02 %cmp_val = uitofp i1 %3 to double %dst_val = getelementptr double, double* %dst, i64 %2 store double %cmp_val, double* %dst_val, align 8 br label %EndBB EndBB: ; preds = %LoopBB, %entry ret void } attributes #0 = { nounwind readnone } attributes #1 = { inlinehint } !nvvm.annotations = !{!0} !0 = !{void (double*, double*, i32)* @kernel, !"kernel", i32 1}
Hi:
 I generate IR by LLVM, and need compile the IR into the PTX, but, I get this error:

nvvmCompileProgram: Failed
test (2, 0): parse expected top-level entity

thanks for any reply.


this is my IR file:


; ModuleID = 'test'
source_filename = "test"
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-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
target triple = "nvptx64-nvidia-cuda"

; Function Attrs: nounwind readnone
declare i32 @llvm.nvvm.read.ptx.sreg.tid.x() #0

; Function Attrs: nounwind readnone
declare i32 @llvm.nvvm.read.ptx.sreg.ntid.x() #0

; Function Attrs: nounwind readnone
declare i32 @llvm.nvvm.read.ptx.sreg.ctaid() #0

; Function Attrs: inlinehint
define i32 @getThreadID() #1 {
get_thread_id_entry:
%0 = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
%1 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid()
%2 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
%3 = mul i32 %0, %1
%4 = add i32 %2, %3
ret i32 %4
}

define void @kernel(double* %src, double* %dst, i32 %length) {
entry:
%0 = call i32 @getThreadID()
%1 = icmp slt i32 %0, %length
br i1 %1, label %LoopBB, label %EndBB

LoopBB: ; preds = %entry
%2 = sext i32 %0 to i64
%src_ptr = getelementptr double, double* %src, i64 %2
%src_val = load double, double* %src_ptr, align 8
%3 = fcmp ult double %src_val, 2.000000e+02
%cmp_val = uitofp i1 %3 to double
%dst_val = getelementptr double, double* %dst, i64 %2
store double %cmp_val, double* %dst_val, align 8
br label %EndBB

EndBB: ; preds = %LoopBB, %entry
ret void
}

attributes #0 = { nounwind readnone }
attributes #1 = { inlinehint }

!nvvm.annotations = !{!0}

!0 = !{void (double*, double*, i32)* @kernel, !"kernel", i32 1}

#1
Posted 12/07/2017 09:42 AM   
I solved it. there is an error declare declare i32 @llvm.nvvm.read.ptx.sreg.ctaid() #0 should be declare i32 @llvm.nvvm.read.ptx.sreg.ctaid.x() #0
I solved it.
there is an error declare
declare i32 @llvm.nvvm.read.ptx.sreg.ctaid() #0
should be
declare i32 @llvm.nvvm.read.ptx.sreg.ctaid.x() #0

#2
Posted 12/08/2017 09:16 AM   
Scroll To Top

Add Reply