LWJGL Forum

Please login or register.

Login with username, password and session length

Author Topic: [Solved] Big Crash with OpenCL clCompileProgram  (Read 403 times)

Evan407

  • Newbie
  • *
  • Offline Offline
  • Posts: 42
[Solved] Big Crash with OpenCL clCompileProgram
« on: June 18, 2017, 22:20:18 »

http://evansgame.com/com/evanstools/opencl/demo/Demo.java
Code: [Select]
    clCompileProgram(program,
                     platforms[0]._devices,
                     "",//options
                     MemoryUtil.NULL,//input header
                     "",//header include name
                     pfn_notify,
                     MemoryUtil.NULL);
throws a massive raging error
Code: [Select]
package com.evanstools.opencl.demo;
import com.evanstools.opencl.*;
import java.nio.*;
import java.io.*;
import org.lwjgl.opencl.CLProgramCallback;
import static com.evanstools.opencl.Platform.*;
import static org.lwjgl.opencl.CL10.*;
import static org.lwjgl.opencl.CL12.*;
import static org.lwjgl.BufferUtils.*;
import org.lwjgl.system.MemoryUtil;
import java.util.*;
class Demo{
  public static void main(String[] args){
    if(args.length == 0){System.out.printf("Demo [demo source]%n");return;}
    //import kernels
    LinkedList<String> KERNEL_SOURCE_LIST = new LinkedList<>();
    try{
      for(Scanner scanner = new Scanner(new File(args[0]));scanner.hasNextLine();KERNEL_SOURCE_LIST.add(scanner.nextLine())){}
    }catch(Exception e){e.printStackTrace();}
    final String[] KERNEL_SOURCE = new String[KERNEL_SOURCE_LIST.size()];
    for(int i = 0;i < KERNEL_SOURCE.length;i++)KERNEL_SOURCE[i] = KERNEL_SOURCE_LIST.get(i);
System.out.printf("Kernel Source Code:%n");
for(String s:KERNEL_SOURCE)System.out.printf("%s%n",s);
    IntBuffer errcode_ret = null;
    long program = clCreateProgramWithSource(platforms[0].context,KERNEL_SOURCE,errcode_ret);
    if(errcode_ret != null){System.out.printf("clCreateProgramWithSource errcode_ret = %d %n",errcode_ret.get());}
    CLProgramCallback pfn_notify = null;
    int returns = clBuildProgram(program,
                                 platforms[0]._devices,
                                 "",//options
                                 pfn_notify,
                                 MemoryUtil.NULL);
    if(returns != CL_SUCCESS)System.out.printf("clBuildError: %d%n",returns);
   
    /*HUGE ERROR clCompileProgram(program,
                     platforms[0]._devices,
                     "",//options
                     MemoryUtil.NULL,//input header
                     "",//header include name
                     pfn_notify,
                     MemoryUtil.NULL);*/
    //index space?
    OpenCL_Buffer openCL_Buffer = buffer(platforms[0],platforms[0].commandQueues[0],1337);
    ByteBuffer bb = openCL_Buffer.buffer;
    System.out.printf("%s%n",bb.toString());
    bb.putInt(1337).flip();
    System.out.printf("%d%n",bb.getInt());
  }
}

and I'm not sure about the html error maybe it's a xss vuln
Logged

darkyellow

  • Newbie
  • *
  • Offline Offline
  • Posts: 22
Re: Big Crash with OpenCL
« Reply #1 on: June 20, 2017, 10:11:05 »

Maybe post the error?
Logged

Evan407

  • Newbie
  • *
  • Offline Offline
  • Posts: 42
Re: Big Crash with OpenCL
« Reply #2 on: June 21, 2017, 03:24:49 »

Maybe post the error?

Quote
Java$ java -cp Dependencies/lwjgl/*:. com.evanstools.opencl.demo.Demo 'com/evanstools/opencl/demo/hello.cl'
Kernel Source Code:
__kernel void hello(__global char* string)
{
string[0] = 'H';
string[1] = 'e';
string[2] = 'l';
string[3] = 'l';
string[4] = 'o';
string[5] = ',';
string[6] = ' ';
string[7] = 'W';
string[8] = 'o';
string[9] = 'r';
string[10] = 'l';
string[11] = 'd';
string[12] = '!';
string[13] = '\0';
}
Number of platforms: 1
Platform id: 140011375165456
Number devices: 1
Platform version: OpenCL 1.2 CUDA 8.0.0
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f56d6d13df4, pid=23871, tid=0x00007f56f677a700
#
# JRE version: OpenJDK Runtime Environment (8.0_131-b11) (build 1.8.0_131-8u131-b11-0ubuntu1.16.04.2-b11)
# Java VM: OpenJDK 64-Bit Server VM (25.131-b11 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [libnvidia-opencl.so.1+0xbedf4]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/evan/Desktop/Java/hs_err_pid23871.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)

The following error or errors occurred while posting this message:
The message exceeds the maximum allowed length (20000 characters).

http://evansgame.com/hs_err_pid23318.log

Code: [Select]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.lwjgl.system.JNI.callPPPPPPPI(JJIJJIJJJJ)I+0
j  org.lwjgl.opencl.CL12.nclCompileProgram(JIJJIJJJJ)I+42
j  org.lwjgl.opencl.CL12.clCompileProgram(JLorg/lwjgl/PointerBuffer;Ljava/lang/CharSequence;JLjava/lang/CharSequence;Lorg/lwjgl/opencl/CLProgramCallbackI;J)I+82
j  com.evanstools.opencl.demo.Demo.main([Ljava/lang/String;)V+275
v  ~StubRoutines::call_stub
Logged

spasi

  • Administrator
  • Nerdus Imperius
  • *****
  • Offline Offline
  • Posts: 1891
Re: Big Crash with OpenCL
« Reply #3 on: June 21, 2017, 09:21:07 »

You're using the wrong overload. Try:

Code: [Select]
clCompileProgram(
    program,
    platforms[0]._devices,
    "",//options
    (PointerBuffer)null,//input header
    null,//header include name
    pfn_notify,
    MemoryUtil.NULL
);

I may end up removing the other overloads, they're indeed confusing.
Logged

Evan407

  • Newbie
  • *
  • Offline Offline
  • Posts: 42
Re: Big Crash with OpenCL
« Reply #4 on: June 22, 2017, 04:45:46 »

You're using the wrong overload. Try:

Code: [Select]
clCompileProgram(
    program,
    platforms[0]._devices,
    "",//options
    (PointerBuffer)null,//input header
    null,//header include name
    pfn_notify,
    MemoryUtil.NULL
);

I may end up removing the other overloads, they're indeed confusing.
Thanks that got it working  8)
Logged