question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot invoke "Object.toString()" because "this.constant" is null when trying to use context.allocateDoubleLocalArray

See original GitHub issue

Describe the bug Continuation of https://github.com/beehive-lab/TornadoVM/issues/157

We are trying to get rid of recompilation of the kernels between invocations in order to get stable code. When we use context.allocateDoubleLocalArraycall in a function, it does not work at all with

Cannot invoke "Object.toString()" because "this.constant" is null

error.

The general question is if it is possible at all to get a static kernel code to be reused by TornadoVM with differing input? Either way the error seems to be a bug.

3538 INFO  [main] gaia.cu7.algo.character.periodsearch.methods.test.MethodLeastSquareComputeComparison  [] - Sequential LSQ: 0.557195801
#pragma OPENCL EXTENSION cl_khr_fp64 : enable  
#pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable  
__kernel void lookupBufferAddress(__global uchar *_heap_base, uint _frame_base, __constant uchar *_constant_region, __local uchar *_local_region, __global int *_atomics)
{

  __global ulong *_frame = (__global ulong *) &_heap_base[_frame_base];


  // BLOCK 0
  _frame[0]  =  (ulong) _heap_base;
}  //  kernel

#pragma OPENCL EXTENSION cl_khr_fp64 : enable  
__kernel void lookupBufferAddress(__global uchar *_heap_base, uint _frame_base, __constant uchar *_constant_region, __local uchar *_local_region, __global int *_atomics)
{

  __global ulong *_frame = (__global ulong *) &_heap_base[_frame_base];


  // BLOCK 0
  _frame[0]  =  (ulong) _heap_base;
}  //  kernel

Cannot invoke "Object.toString()" because "this.constant" is null
Unable to compile task task PeriodSearch.t0 - computeKernel
[tornado.drivers.opencl@0.13-dev/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.compileTask(OCLTornadoDevice.java:289), tornado.drivers.opencl@0.13-dev/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.compileJavaToAccelerator(OCLTornadoDevice.java:321), tornado.driv
ers.opencl@0.13-dev/uk.ac.manchester.tornado.drivers.opencl.runtime.OCLTornadoDevice.installCode(OCLTornadoDevice.java:449), tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.TornadoVM.compileTaskFromBytecodeToBinary(TornadoVM.java:467), tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runt
ime.TornadoVM.execute(TornadoVM.java:743), tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.TornadoVM.execute(TornadoVM.java:227), tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskSchedule.scheduleInner(TornadoTaskSchedule.java:630), tornado.runtime@0.13-dev/uk.ac.
manchester.tornado.runtime.tasks.TornadoTaskSchedule.schedule(TornadoTaskSchedule.java:912), tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskSchedule.schedule(TornadoTaskSchedule.java:920), tornado.api@0.13-dev/uk.ac.manchester.tornado.api.TaskSchedule.execute(TaskSchedule
.java:306), gaia.cu7.algo.character.periodsearch.methods.MethodLeastSquareGPU.computeMainKernel(MethodLeastSquareGPU.java:419), gaia.cu7.algo.character.periodsearch.methods.MethodLeastSquareGPU.compute(MethodLeastSquareGPU.java:367), gaia.cu7.algo.character.periodsearch.methods.MethodLeastSquareGPU.
computeFrequencyGrammePower(MethodLeastSquareGPU.java:116), gaia.cu7.algo.character.periodsearch.methods.PeriodMethod.extremaExtractionAfterTimeseriesAreSet(PeriodMethod.java:813), gaia.cu7.algo.character.periodsearch.methods.PeriodMethod.search(PeriodMethod.java:719), gaia.cu7.algo.character.period
search.methods.PeriodMethod.search(PeriodMethod.java:679), gaia.cu7.algo.character.periodsearch.methods.PeriodMethod.search(PeriodMethod.java:646), gaia.cu7.algo.character.periodsearch.methods.test.MethodLeastSquareComputeComparison.testGPUGaiaSource4660664932119220224(MethodLeastSquareComputeCompar
ison.java:175), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method), java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77), java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43), 
java.base/java.lang.reflect.Method.invoke(Method.java:568), junit@4.13.1/org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59), junit@4.13.1/org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12), junit@4.13.1/org.junit.runners.model.Framew
orkMethod.invokeExplosively(FrameworkMethod.java:56), junit@4.13.1/org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17), junit@4.13.1/org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26), junit@4.13.1/org.junit.runners.ParentRunner$3.evaluate(Par
entRunner.java:306), junit@4.13.1/org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100), junit@4.13.1/org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366), junit@4.13.1/org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103), junit@4
.13.1/org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63), junit@4.13.1/org.junit.runners.ParentRunner$4.run(ParentRunner.java:331), junit@4.13.1/org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79), junit@4.13.1/org.junit.runners.ParentRunner.runChildren(Par
entRunner.java:329), junit@4.13.1/org.junit.runners.ParentRunner.access$100(ParentRunner.java:66), junit@4.13.1/org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293), junit@4.13.1/org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26), junit@4.13.1/org.junit.interna
l.runners.statements.RunAfters.evaluate(RunAfters.java:27), junit@4.13.1/org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306), junit@4.13.1/org.junit.runners.ParentRunner.run(ParentRunner.java:413), org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:9
3), org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:40), org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:529), org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:756), org.eclipse.jdt.internal.junit.r
unner.RemoteTestRunner.run(RemoteTestRunner.java:452), org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:210)]
	tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.TornadoVM.compileTaskFromBytecodeToBinary(TornadoVM.java:471)
	tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.TornadoVM.execute(TornadoVM.java:743)
	tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.TornadoVM.execute(TornadoVM.java:227)
	tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskSchedule.scheduleInner(TornadoTaskSchedule.java:630)
	tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskSchedule.schedule(TornadoTaskSchedule.java:912)
	tornado.runtime@0.13-dev/uk.ac.manchester.tornado.runtime.tasks.TornadoTaskSchedule.schedule(TornadoTaskSchedule.java:920)
	tornado.api@0.13-dev/uk.ac.manchester.tornado.api.TaskSchedule.execute(TaskSchedule.java:306)

How To Reproduce

public static void computeKernel(KernelContext context,  int tileSize, final double infirstScanFrequency, final double frequencyStep, final double deltaEpsilon, final double[] normObsTimes, final double[] normObsValues, final double[] amplitudes, int[] localGroups) 
	{
		
		int tileIdx = context.globalIdx;

                //testing kernel params
		localGroups[0] = context.localGroupSizeX;
		localGroups[1] = context.globalGroupSizeX;
		localGroups[2] = context.localIdx;
		localGroups[3] = context.globalIdx;
		localGroups[4+context.globalIdx]=context.globalIdx;
                //\testing kernel params		

		int startFreqIdx = tileIdx * tileSize;
		int nObservations = normObsTimes.length;		
		
		final double omega =  (infirstScanFrequency + startFreqIdx * frequencyStep) * 2 * Math.PI;		
		// starting frequency
		final double deltaOmega = frequencyStep * 2 * Math.PI;		
		// frequency step
		final double[] sumSx = context.allocateDoubleLocalArray(constTileSize); // <--  does not work
//		final double[] sumSx = new double[constTileSize]; <-- this does not give the reported error (Cannot invoke "Object.toString()" because "this.constant" is null)
		// sum of sin(obsTimes[i]*2pi*f)
		final double[] sumCx = new double[constTileSize]; 		

Expected behavior Dynamic local arrays to be supported, not-erroring out or some kind of compile-time check preventing usage of local arrays.

A clear and concise description of what you expected to happen.

Computing system setup (please complete the following information):

  • OS: MacOS, centos7
  • OpenCL Version 1.2,2,3
  • TornadoVM commit 0.13-dev

Additional context Is there an example checking what are limits of the underlying hardware to know what would be the max size of dynamicall allocated constTileSize in our example? It does not look like is related to context.allocateDoubleLocalArray argument though or underlying hw capabilities.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jjfumerocommented, Dec 7, 2021

Hi @yazun , we can take offline discussions to understand more about these issues. We are happy to help here.

0reactions
jjfumerocommented, Dec 20, 2021

I will close this issue. Please, feel free to open new ones for new comments/feedback or bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot invoke "Object.toString()" because the return value of ...
1 Answer 1 ... So if you don't want to set default value, you can check buttons[i].getIcon() != null and if it's true,...
Read more >
Object.prototype.toString() - JavaScript - MDN Web Docs
The toString() method returns a string representing the object. This method is meant to be overridden by derived objects for custom type conversion...
Read more >
Java NullPointerException Avoidance and Enhancement Tactics
NullPointerException: Cannot invoke "Object.toString()" because "dustin.examples.nullsafe.tactics.NullSafeTactics.NULL_OBJECT" is null ...
Read more >
JavaScript String toString() Method - W3Schools
The toString() method is used internally by JavaScript when an object needs to be displayed as a text (like in HTML), or when...
Read more >
NullPointerException :: getMessage() in Java 14
I really recommend you to try it, but it looks like these: Cannot invoke “Object.toString()” because “object” is null; Cannot invoke “Object.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found