Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions src/main/java/com/aparapi/internal/writer/BlockWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,23 @@ public void writeInstruction(Instruction _instruction) throws CodeGenException {
write(localVariableInfo.getVariableName());
}
} else {
if (assignToLocalVariable.isDeclaration()) {
final String descriptor = localVariableInfo.getVariableDescriptor();
// Arrays always map to __global arrays
if (descriptor.startsWith("[")) {
write(" __global ");
}
write(convertType(descriptor, true, false));
}
if (localVariableInfo == null) {
throw new CodeGenException("outOfScope" + _instruction.getThisPC() + " = ");
// javac can omit LocalVariableTable entries for unused stores at the
// end of a scope. Preserve any RHS side effects but do not emit a
// synthetic local name that cannot be recovered from the bytecode.
for (Instruction operand = _instruction.getFirstChild(); operand != null; operand = operand.getNextExpr()) {
writeInstruction(operand);
}
return;
} else {
if (assignToLocalVariable.isDeclaration()) {
final String descriptor = localVariableInfo.getVariableDescriptor();
// Arrays always map to __global arrays
if (descriptor.startsWith("[")) {
write(" __global ");
}
write(convertType(descriptor, true, false));
}
write(localVariableInfo.getVariableName() + " = ");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/aparapi/codegen/test/ArbitraryScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ __kernel void run(
count--;
}
}
int value = (256 * count) / this->maxIterations;
(256 * count) / this->maxIterations;
}
float scaleSquare = 1.0f;
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.aparapi.codegen.test;

import org.junit.Ignore;
import org.junit.Test;

public class ArbitraryScopeTest extends com.aparapi.codegen.CodeGenJUnitBase {
Expand Down Expand Up @@ -68,7 +67,7 @@ public class ArbitraryScopeTest extends com.aparapi.codegen.CodeGenJUnitBase {
+ " count--;\n"
+ " }\n"
+ " }\n"
+ " int value = (256 * count) / this->maxIterations;\n"
+ " (256 * count) / this->maxIterations;\n"
+ " }\n"
+ " float scaleSquare = 1.0f;\n"
+ " return;\n"
Expand All @@ -77,13 +76,11 @@ public class ArbitraryScopeTest extends com.aparapi.codegen.CodeGenJUnitBase {
+ " "};
private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null;

@Ignore
@Test
public void ArbitraryScopeTest() {
test(com.aparapi.codegen.test.ArbitraryScope.class, expectedException, expectedOpenCL);
}

@Ignore
@Test
public void ArbitraryScopeTestWorksWithCaching() {
test(com.aparapi.codegen.test.ArbitraryScope.class, expectedException, expectedOpenCL);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/aparapi/codegen/test/NonNullCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ __kernel void run(
this->passid = passid;
{
if (this->ints != NULL){
int value = this->ints[0];
this->ints[0];
}
return;
}
Expand Down
30 changes: 26 additions & 4 deletions src/test/java/com/aparapi/codegen/test/NonNullCheckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,36 @@
*/
package com.aparapi.codegen.test;

import com.aparapi.internal.exception.CodeGenException;
import org.junit.Ignore;
import org.junit.Test;

public class NonNullCheckTest extends com.aparapi.codegen.CodeGenJUnitBase {

private static final String[] expectedOpenCL = null;
private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = CodeGenException.class;
private static final String[] expectedOpenCL = {
"typedef struct This_s{\n"
+ " __global int *ints;\n"
+ " int passid;\n"
+ " }This;\n"
+ " int get_pass_id(This *this){\n"
+ " return this->passid;\n"
+ " }\n"
+ "\n"
+ " __kernel void run(\n"
+ " __global int *ints,\n"
+ " int passid\n"
+ " ){\n"
+ " This thisStruct;\n"
+ " This* this=&thisStruct;\n"
+ " this->ints = ints;\n"
+ " this->passid = passid;\n"
+ " {\n"
+ " if (this->ints != NULL){\n"
+ " this->ints[0];\n"
+ " }\n"
+ " return;\n"
+ " }\n"
+ " }\n"
+ " "};
private static final Class<? extends com.aparapi.internal.exception.AparapiException> expectedException = null;

@Test
public void NonNullCheckTest() {
Expand Down