Quantcast

OpenCL Memory Error

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

OpenCL Memory Error

Edgar Esparza
Im running this small test and I keep getting a memory error that I have no idea why its happening.

Test:
public class BesselColtTest {
       
        private static int NUMEL = 5000;
       
        public static void main (String [] args) {
                OpenCLUtil.initializeOpenCL();
               
                for (int i = 1; i <= 50; i++) {
                        NUMEL = i * 5000;
                       
                        double [] vals = new double [NUMEL];
                        for (int j = 0; j < NUMEL; j++) {
                                vals[j] = j * ((double)1 / NUMEL) * 65535;
                        }
                        runCLCode(vals);
                       
                        if (vals != null) { System.out.println(" OK "); }
                }
        }
       
        public static void runCLCode(double [] vals) {

                DoubleBuffer fBuffer = Buffers.newDirectDoubleBuffer(vals);
               
                long start = System.nanoTime();
                fBuffer = OpenCLUtil.besselj1_d(fBuffer);
                System.out.print("Elapsed time: " + (double)(System.nanoTime() - start) / 1000000000 + " sec");
               
                double [] gVals = new double[vals.length];
               
                fBuffer.get(gVals);
        }
}

Error from log:
j  com.jogamp.opencl.llb.impl.CLAbstractImpl.clReleaseMemObject(J)I+28

Buffer Source where error occurs:
public static DoubleBuffer besselj1_d(DoubleBuffer pBuffer) {
               
                //Create a new buffer that OpenCL can use with the input buffer
                CLBuffer<DoubleBuffer> buffer = maxFLOPSContextD.createBuffer(pBuffer, CLMemory.Mem.READ_WRITE);
               
                CLKernel BESSJ1_kernel = getKernel("besselj1_d");
               
                //See how many threads can be used to do the calculation
                int localWorkSize = maxFLOPSQueueD.getDevice().getMaxWorkGroupSize();
                int modulus = pBuffer.capacity() % localWorkSize;
                int globalWorkSize = (modulus == 0) ? pBuffer.capacity() : localWorkSize + pBuffer.capacity() - modulus;
               
                //Send input arguments to kernel
                BESSJ1_kernel.setArg(0, buffer);
               
                //Send the buffer to OpenCL and do all calculations
                maxFLOPSQueueD.putWriteBuffer(buffer, false)
                        .put1DRangeKernel(BESSJ1_kernel, 0, globalWorkSize, localWorkSize)
                        .putBarrier()
                        .putReadBuffer(buffer, true)
                        .putBarrier();
               
                //Make sure all the calculations were finished and reset the kernel
                maxFLOPSQueueD.finish();
                maxFLOPSQueueD.flush();
                BESSJ1_kernel.rewind();
               
                //Retrieve the new buffer and free up its memory
                pBuffer = buffer.getBuffer();
               
                if (!buffer.isReleased()) { buffer.release(); }  //here for some reason the memory is not freed
               
                return pBuffer;
        }

i know its super specific but i would appreciate any help.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: OpenCL Memory Error

gouessej
Administrator
Could you post the full logs please?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: OpenCL Memory Error

David Kim
Posting on behalf of Edgar.  Here is one of the logs from the crashes.  They're all pretty much identical.

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000077efa9bd, pid=5632, tid=1424
#
# JRE version: 7.0_02-b13
# Java VM: Java HotSpot(TM) 64-Bit Server VM (22.0-b10 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [ntdll.dll+0x3a9bd]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------

Current thread (0x0000000001f73000):  JavaThread "main" [_thread_in_native, id=1424, stack(0x00000000021a0000,0x00000000022a0000)]

siginfo: ExceptionCode=0xc0000005, writing address 0x000000000c10a95a

Registers:
RAX=0x0000000000009eba, RBX=0x000000000c06bdb0, RCX=0x0000000000013d74, RDX=0x00000000ffff002d
RSP=0x000000000229f410, RBP=0x00000000086b0000, RSI=0x000000000601d6e0, RDI=0x000000000c09ddb0
R8 =0x00000000ffffffff, R9 =0x0000000000000000, R10=0x0000000000000007, R11=0x000007fffffdc000
R12=0x0000000005fa76e0, R13=0x000000000229f490, R14=0x0000000000000000, R15=0x0000000000000001
RIP=0x0000000077efa9bd, EFLAGS=0x0000000000010216

Top of Stack: (sp=0x000000000229f410)
0x000000000229f410:   0000000077f89510 000000000c09ddc0
0x000000000229f420:   000000000229f490 0000000000000000
0x000000000229f430:   0000000000000000 000000000c06bdc0
0x000000000229f440:   0000000000000000 00000000086c0080
0x000000000229f450:   0000000000000001 0000000077ef5a40
0x000000000229f460:   000000000c06bdb0 000000000229f750
0x000000000229f470:   0000000000000000 00000000086b0000
0x000000000229f480:   0000000000000101 0000000077ef6040
0x000000000229f490:   0000000000009eba 000000000229f750
0x000000000229f4a0:   000000000c06bdb0 00000000086b0000
0x000000000229f4b0:   0000000000000100 0000000000000000
0x000000000229f4c0:   00000000086b0000 000000000229f540
0x000000000229f4d0:   00000000086b0000 0000000000031f03
0x000000000229f4e0:   000000000c06bdbd 0000000180001cca
0x000000000229f4f0:   0000000000000000 000000000c06bdb8
0x000000000229f500:   0000000000000000 0000000077ef6040

Instructions: (pc=0x0000000077efa9bd)
0x0000000077efa99d:   40 f6 43 0d 10 41 0f b7 45 00 66 89 43 08 0f 85
0x0000000077efa9ad:   04 a0 ff ff 49 8b 4d 00 41 0f b7 45 00 48 03 c9
0x0000000077efa9bd:   66 89 44 cb 0a e9 ee 9f ff ff 0f b6 43 0f 3c 40
0x0000000077efa9cd:   0f 83 7d 2d 04 00 0f b6 c0 48 8b 8c c5 a0 00 00


Register to memory mapping:

RAX=0x0000000000009eba is an unknown value
RBX=0x000000000c06bdb0 is an unknown value
RCX=0x0000000000013d74 is an unknown value
RDX=0x00000000ffff002d is an unknown value
RSP=0x000000000229f410 is pointing into the stack for thread: 0x0000000001f73000
RBP=0x00000000086b0000 is an unknown value
RSI=0x000000000601d6e0 is an unknown value
RDI=0x000000000c09ddb0 is an unknown value
R8 =0x00000000ffffffff is an unknown value
R9 =0x0000000000000000 is an unknown value
R10=0x0000000000000007 is an unknown value
R11=0x000007fffffdc000 is an unknown value
R12=0x0000000005fa76e0 is an unknown value
R13=0x000000000229f490 is pointing into the stack for thread: 0x0000000001f73000
R14=0x0000000000000000 is an unknown value
R15=0x0000000000000001 is an unknown value


Stack: [0x00000000021a0000,0x00000000022a0000],  sp=0x000000000229f410,  free space=1021k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [ntdll.dll+0x3a9bd]  RtlQueryInformationActivationContext+0x2cd

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  com.jogamp.opencl.llb.impl.CLAbstractImpl.dispatch_clReleaseMemObject1(JJ)I+0
j  com.jogamp.opencl.llb.impl.CLAbstractImpl.clReleaseMemObject(J)I+28
j  com.jogamp.opencl.CLMemory.release()V+12
j  com.jogamp.opencl.CLBuffer.release()V+39
j  miatool.util.OpenCLUtil.besselj1_d(Ljava/nio/DoubleBuffer;)Ljava/nio/DoubleBuffer;+138
j  testClasses.BesselColtTest.runCLCode([D)V+10
J  testClasses.BesselColtTest.main([Ljava/lang/String;)V
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x0000000006039000 JavaThread "Service Thread" daemon [_thread_blocked, id=6320, stack(0x0000000006cf0000,0x0000000006df0000)]
  0x000000000602e800 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=5196, stack(0x0000000006bf0000,0x0000000006cf0000)]
  0x0000000006029800 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=5700, stack(0x0000000006af0000,0x0000000006bf0000)]
  0x0000000006027000 JavaThread "Attach Listener" daemon [_thread_blocked, id=5324, stack(0x00000000069f0000,0x0000000006af0000)]
  0x0000000006022000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=6968, stack(0x00000000068f0000,0x00000000069f0000)]
  0x0000000005f7e800 JavaThread "Finalizer" daemon [_thread_blocked, id=5052, stack(0x00000000067f0000,0x00000000068f0000)]
  0x0000000005f78000 JavaThread "Reference Handler" daemon [_thread_blocked, id=4284, stack(0x00000000066f0000,0x00000000067f0000)]
=>0x0000000001f73000 JavaThread "main" [_thread_in_native, id=1424, stack(0x00000000021a0000,0x00000000022a0000)]

Other Threads:
  0x0000000005f73800 VMThread [stack: 0x00000000065f0000,0x00000000066f0000] [id=948]
  0x0000000006046000 WatcherThread [stack: 0x0000000006df0000,0x0000000006ef0000] [id=3248]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 PSYoungGen      total 38208K, used 7086K [0x00000007d5600000, 0x00000007d80a0000, 0x0000000800000000)
  eden space 32768K, 21% used [0x00000007d5600000,0x00000007d5ceb8f0,0x00000007d7600000)
  from space 5440K, 0% used [0x00000007d7b50000,0x00000007d7b50000,0x00000007d80a0000)
  to   space 5440K, 0% used [0x00000007d7600000,0x00000007d7600000,0x00000007d7b50000)
 PSOldGen        total 87296K, used 0K [0x0000000780200000, 0x0000000785740000, 0x00000007d5600000)
  object space 87296K, 0% used [0x0000000780200000,0x0000000780200000,0x0000000785740000)
 PSPermGen       total 21248K, used 5539K [0x000000077b000000, 0x000000077c4c0000, 0x0000000780200000)
  object space 21248K, 26% used [0x000000077b000000,0x000000077b568fc8,0x000000077c4c0000)

Code Cache  [0x00000000022d0000, 0x0000000002540000, 0x00000000052d0000)
 total_blobs=390 nmethods=25 adapters=318 free_code_cache=48623Kb largest_free_block=49783744

Dynamic libraries:
0x0000000140000000 - 0x0000000140033000 C:\Program Files\Java\jdk1.7.0_02\bin\javaw.exe
0x0000000077ec0000 - 0x0000000077ffc000 C:\WINDOWS\system32\ntdll.dll
0x0000000077d40000 - 0x0000000077eb3000 C:\WINDOWS\system32\kernel32.dll
0x000007ff7fee0000 - 0x000007ff7ffe6000 C:\WINDOWS\system32\ADVAPI32.dll
0x000007ff7fd30000 - 0x000007ff7fed0000 C:\WINDOWS\system32\RPCRT4.dll
0x000007ff7e9c0000 - 0x000007ff7e9e2000 C:\WINDOWS\system32\Secur32.dll
0x0000000077c20000 - 0x0000000077d2c000 C:\WINDOWS\system32\USER32.dll
0x000007ff7fc90000 - 0x000007ff7fd2c000 C:\WINDOWS\system32\GDI32.dll
0x000007ff7f000000 - 0x000007ff7f187000 C:\WINDOWS\WinSxS\AMD64_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.4770_x-ww_3807D667\COMCTL32.dll
0x000007ff7fc00000 - 0x000007ff7fc86000 C:\WINDOWS\system32\msvcrt.dll
0x000007ff7ef60000 - 0x000007ff7effb000 C:\WINDOWS\system32\SHLWAPI.dll
0x000007ff7d500000 - 0x000007ff7d539000 C:\WINDOWS\system32\IMM32.DLL
0x000007ff69300000 - 0x000007ff6930d000 C:\WINDOWS\system32\LPK.DLL
0x000007ff78e80000 - 0x000007ff78f0e000 C:\WINDOWS\system32\USP10.dll
0x000000006fa00000 - 0x000000006fa38000 C:\PROGRA~2\Sophos\SOPHOS~1\SOPHOS~2.DLL
0x000007ff7e380000 - 0x000007ff7e390000 C:\WINDOWS\system32\PSAPI.DLL
0x0000000079730000 - 0x0000000079801000 C:\Program Files\Java\jdk1.7.0_02\jre\bin\msvcr100.dll
0x000000006db00000 - 0x000000006e1da000 C:\Program Files\Java\jdk1.7.0_02\jre\bin\server\jvm.dll
0x000007ff770f0000 - 0x000007ff770fa000 C:\WINDOWS\system32\WSOCK32.dll
0x000007ff77310000 - 0x000007ff77340000 C:\WINDOWS\system32\WS2_32.dll
0x000007ff77140000 - 0x000007ff7714c000 C:\WINDOWS\system32\WS2HELP.dll
0x000007ff7e240000 - 0x000007ff7e290000 C:\WINDOWS\system32\WINMM.dll
0x000000006d8f0000 - 0x000000006d8ff000 C:\Program Files\Java\jdk1.7.0_02\jre\bin\verify.dll
0x000000006d470000 - 0x000000006d498000 C:\Program Files\Java\jdk1.7.0_02\jre\bin\java.dll
0x000000006d940000 - 0x000000006d955000 C:\Program Files\Java\jdk1.7.0_02\jre\bin\zip.dll
0x0000000068000000 - 0x000000006804c000 C:\WINDOWS\system32\rsaenh.dll
0x000007ff7c680000 - 0x000007ff7c78a000 C:\WINDOWS\system32\USERENV.dll
0x000007ff77370000 - 0x000007ff77409000 C:\WINDOWS\system32\netapi32.dll
0x000000006d720000 - 0x000000006d739000 C:\Program Files\Java\jdk1.7.0_02\jre\bin\net.dll
0x000007ff771b0000 - 0x000007ff7722d000 C:\WINDOWS\System32\mswsock.dll
0x000007ff7e8f0000 - 0x000007ff7e93f000 C:\WINDOWS\system32\DNSAPI.dll
0x000007ff7e9f0000 - 0x000007ff7e9fb000 C:\WINDOWS\System32\winrnr.dll
0x000007ff7e950000 - 0x000007ff7e9b6000 C:\WINDOWS\system32\WLDAP32.dll
0x000007ff7ea00000 - 0x000007ff7ea07000 C:\WINDOWS\system32\rasadhlp.dll
0x000000006d740000 - 0x000000006d751000 C:\Program Files\Java\jdk1.7.0_02\jre\bin\nio.dll
0x00000000637c0000 - 0x00000000637ca000 C:\Documents and Settings\david\Local Settings\Temp\jogamp\file_cache\jln3275236539708632285\jln979247320079212700\gluegen-rt.dll
0x000000006c580000 - 0x000000006c592000 C:\Documents and Settings\david\Local Settings\Temp\jogamp\file_cache\jln3275236539708632285\jln979247320079212700\jocl.dll
0x0000000180000000 - 0x0000000180012000 C:\WINDOWS\system32\OpenCL.dll
0x0000000007490000 - 0x00000000085a8000 C:\WINDOWS\system32\amdocl64.dll
0x000007ff724e0000 - 0x000007ff7261e000 C:\WINDOWS\system32\dbghelp.dll
0x000007ff7fbf0000 - 0x000007ff7fbfb000 C:\WINDOWS\system32\VERSION.dll
0x0000000069000000 - 0x0000000069ac0000 C:\WINDOWS\system32\aticaldd64.dll
0x000000000aef0000 - 0x000000000af49000 C:\WINDOWS\system32\atiadlxx.dll
0x000007ff7f190000 - 0x000007ff7fb9c000 C:\WINDOWS\system32\SHELL32.dll
0x000007ff7dac0000 - 0x000007ff7dc38000 C:\WINDOWS\system32\SETUPAPI.dll
0x0000000078130000 - 0x00000000781f9000 C:\WINDOWS\WinSxS\amd64_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.6195_x-ww_76301166\MSVCR80.dll
0x000007ff7e3e0000 - 0x000007ff7e430000 C:\WINDOWS\system32\WINTRUST.dll
0x000007ff7d370000 - 0x000007ff7d4cf000 C:\WINDOWS\system32\CRYPT32.dll
0x000007ff7d340000 - 0x000007ff7d36c000 C:\WINDOWS\system32\MSASN1.dll
0x000007ff7e470000 - 0x000007ff7e483000 C:\WINDOWS\system32\imagehlp.dll
0x000000000b8d0000 - 0x000000000b8d8000 C:\DOCUME~1\david\LOCALS~1\Temp\OCL9414.tmp.dll
0x000000000b8e0000 - 0x000000000b8e7000 C:\DOCUME~1\david\LOCALS~1\Temp\OCL9418.tmp.dll
0x000000000b8f0000 - 0x000000000b8f6000 C:\DOCUME~1\david\LOCALS~1\Temp\OCL941B.tmp.dll
0x000000000b910000 - 0x000000000b916000 C:\DOCUME~1\david\LOCALS~1\Temp\OCL941E.tmp.dll
0x000000000b920000 - 0x000000000b927000 C:\DOCUME~1\david\LOCALS~1\Temp\OCL9421.tmp.dll
0x000000000b930000 - 0x000000000b936000 C:\DOCUME~1\david\LOCALS~1\Temp\OCL9424.tmp.dll

VM Arguments:
jvm_args: -Djava.library.path=H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib;H:\eclipse_workspace\MIATool\JOGAMPx64\lib -Dfile.encoding=Cp1252 -Xbootclasspath:C:\Program Files\Java\jdk1.7.0_02\lib\dt.jar;C:\Program Files\Java\jdk1.7.0_02\lib\jconsole.jar;C:\Program Files\Java\jdk1.7.0_02\lib\sa-jdi.jar;C:\Program Files\Java\jdk1.7.0_02\lib\tools.jar;C:\Program Files\Java\jdk1.7.0_02\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_02\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_02\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_02\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_02\jre\lib\charsets.jar
java_command: testClasses.BesselColtTest
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=C:\Program Files\Java\jdk1.7.0
PATH=C:/Program Files/Java/jdk1.7.0_02/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0_02/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0_02/bin/../jre/lib/amd64;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\MATLAB\R2011a\runtime\win64;C:\Program Files\MATLAB\R2011a\bin;C:\Program Files\MATLAB\R2010b\runtime\win64;C:\Program Files\MATLAB\R2010b\bin;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\SlikSvn\bin\;C:\Program Files\MATLAB\MATLAB Compiler Runtime\v716\runtime\win64;C:\Program Files\TortoiseSVN\bin;C:\MinGW\bin;C:\MinGW\msys\1.0\bin;C:\MinGW64\bin;C:\Program Files (x86)\Java\jdk1.6.0_26\include;C:\Program Files (x86)\Java\jdk1.6.0_26\jre\bin\client;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\doxygen\bin;H:\eclipse;
USERNAME=david
OS=Windows_NT
PROCESSOR_IDENTIFIER=EM64T Family 6 Model 30 Stepping 5, GenuineIntel



---------------  S Y S T E M  ---------------

OS: Windows XP x64 Edition Build 3790 Service Pack 2

CPU:total 4 (4 cores per cpu, 1 threads per core) family 6 model 30 stepping 5, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt

Memory: 4k page, physical 8378292k(3544252k free), swap 11944836k(6963488k free)

vm_info: Java HotSpot(TM) 64-Bit Server VM (22.0-b10) for windows-amd64 JRE (1.7.0_02-b13), built on Nov 17 2011 13:51:15 by "java_re" with unknown MS VC++:1600

time: Fri Aug 03 11:32:39 2012
elapsed time: 5 seconds
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: OpenCL Memory Error

Joseph Jennings
Hello all,

I am getting this same error. David, were you able to resolve it? If so, could you please post how you did so? Or, anybody else that might have some additional insight on how to resolve this issue, your comments will be greatly appreciated.

Thank you,

Joseph
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: OpenCL Memory Error

gouessej
Administrator
Please test with David's example and the very latest version of JOCL. If this bug is still reproducible, fill a bug report, don't forget to mention the version number of your OpenCL driver, your graphics card, ...
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: OpenCL Memory Error

Wade Walker
Administrator
In reply to this post by Joseph Jennings
Hi Joseph,

I tried to duplicate David's error last night, but his code sample is not complete (there's no kernel, and he leaves out his OpenCL init code), so I can't compile and run it. Do you have a small, compilable example I can use to try to debug this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: OpenCL Memory Error

gouessej
Administrator
Wade Walker wrote
his code sample is not complete (there's no kernel, and he leaves out his OpenCL init code), so I can't compile and run it
Oh my ... How can they expect any help without providing at least a SSCCE?
Loading...