├── .cz.json ├── src ├── test │ ├── resources │ │ └── squarer.cl │ └── java │ │ └── com │ │ └── aparapi │ │ ├── codegen │ │ └── test │ │ │ ├── PreDecrement.java │ │ │ ├── Assign2DIntArray.java │ │ │ ├── IncField.java │ │ │ ├── AssignField.java │ │ │ ├── EmptyIfBlock.java │ │ │ ├── Access2DIntArray.java │ │ │ ├── StaticFieldStore.java │ │ │ ├── UsesNew.java │ │ │ ├── ReturnIntArrayNew.java │ │ │ ├── ReturnByteArrayNew.java │ │ │ ├── ReturnLongArrayNew.java │ │ │ ├── PostIncIntField.java │ │ │ ├── ReturnFloatArrayNew.java │ │ │ ├── ReturnShortArrayNew.java │ │ │ ├── PreIncIntField.java │ │ │ ├── ReturnDoubleArrayNew.java │ │ │ ├── AccessNested2DIntArray.java │ │ │ ├── PostIncByteField.java │ │ │ ├── PreIncByteField.java │ │ │ ├── ReturnBooleanNewArray.java │ │ │ ├── AssignAndPassAsParameterSimple.java │ │ │ ├── ReturnLongArrayVar.java │ │ │ ├── Break.java │ │ │ ├── ForEach.java │ │ │ ├── EntrypointRecursion.java │ │ │ ├── CallObject.java │ │ │ ├── FusedMultiplyAdd.java │ │ │ ├── UseObject.java │ │ │ ├── DirectRecursion.java │ │ │ ├── ForBreak.java │ │ │ ├── ObjectRefCopy.java │ │ │ ├── Sequence.java │ │ │ ├── WideInc.java │ │ │ ├── Interface.java │ │ │ ├── EmptyWhileWithInc.java │ │ │ ├── PostIncLocalStandalone.java │ │ │ ├── PreIncLocalStandalone.java │ │ │ ├── ForAsFirst.java │ │ │ ├── WhileEmptyLoop.java │ │ │ ├── WhileWithoutMutator.java │ │ │ ├── VarargsForEach.java │ │ │ ├── IndirectRecursion.java │ │ │ ├── ObjectWithinObject.java │ │ │ ├── CallGetPassId.java │ │ │ ├── VarargsSimple.java │ │ │ ├── NaN.java │ │ │ ├── CharArrayField.java │ │ │ ├── PostDecPostInc.java │ │ │ ├── PreDecPostInc.java │ │ │ ├── For.java │ │ │ ├── TernaryNested.java │ │ │ ├── PostDecLocal.java │ │ │ ├── PostIncLocal.java │ │ │ ├── ForAnd.java │ │ │ ├── PreIncLocal.java │ │ │ ├── UsesThrow.java │ │ │ ├── EarlyReturn.java │ │ │ ├── PostIncLocalTwice.java │ │ │ ├── While.java │ │ │ ├── PostIncArrayIndexAndElement.java │ │ │ ├── PreDecArrayIndexAndElement.java │ │ │ ├── PreIncArrayIndexAndElement.java │ │ │ ├── PreIncLocalTwice.java │ │ │ ├── SynchronizedMethods.java │ │ │ ├── ArrayTortureIssue35.java │ │ │ ├── MultipleAssign.java │ │ │ ├── DoWhile.java │ │ │ ├── If.java │ │ │ ├── NonNullCheck.java │ │ │ ├── NewLocalArray.java │ │ │ ├── AccessIntArray.java │ │ │ ├── BreakTest.java │ │ │ ├── Ex.java │ │ │ ├── PostIncInt.java │ │ │ ├── FloatParamsSimple.java │ │ │ ├── AccessLongArray.java │ │ │ ├── ClassHasStaticMethodSimple.java │ │ │ ├── ForEachTest.java │ │ │ ├── ForIf.java │ │ │ ├── Frem.java │ │ │ ├── LongCompares.java │ │ │ ├── NullCheck.java │ │ │ ├── ForBreakTest.java │ │ │ ├── IfAnd.java │ │ │ ├── IfOr.java │ │ │ ├── IncFieldTest.java │ │ │ ├── UsesNewTest.java │ │ │ ├── AccessShortArray.java │ │ │ ├── CharType.java │ │ │ ├── InterfaceTest.java │ │ │ ├── AccessFloatArray.java │ │ │ ├── CallObjectTest.java │ │ │ ├── PreIncInt.java │ │ │ ├── UseObjectTest.java │ │ │ ├── UsesThrowTest.java │ │ │ ├── AssignFieldTest.java │ │ │ ├── If_While_Else.java │ │ │ ├── ReturnPostIncInt.java │ │ │ ├── ReturnPreIncInt.java │ │ │ ├── LongCompare.java │ │ │ ├── VarargsSimpleTest.java │ │ │ ├── Continue.java │ │ │ ├── DirectRecursionTest.java │ │ │ ├── IfAndAnd.java │ │ │ ├── IfOrOr.java │ │ │ ├── PreIncIntFieldTest.java │ │ │ ├── VarargsForEachTest.java │ │ │ ├── PostIncIntFieldTest.java │ │ │ ├── PreIncByteFieldTest.java │ │ │ ├── FirstAssignInExpression.java │ │ │ ├── Loops.java │ │ │ ├── IndirectRecursionTest.java │ │ │ ├── NonNullCheckTest.java │ │ │ ├── PostIncByteFieldTest.java │ │ │ ├── ReturnIntArrayNewTest.java │ │ │ ├── StaticFieldStoreTest.java │ │ │ ├── ReturnLongArrayNewTest.java │ │ │ ├── EntrypointRecursionTest.java │ │ │ ├── IfElse.java │ │ │ ├── ReturnFloatArrayNewTest.java │ │ │ ├── ReturnShortArrayNewTest.java │ │ │ ├── Drem.java │ │ │ ├── ReturnDoubleArrayNewTest.java │ │ │ ├── SynchronizedMethodsTest.java │ │ │ ├── Ternary.java │ │ │ ├── IfBooleanOrOrOr.java │ │ │ ├── ReturnBooleanNewArrayTest.java │ │ │ ├── ReturnByteArrayNewTest.java │ │ │ └── AccessDoubleArray.java │ │ └── runtime │ │ ├── OriginalKernelManager.java │ │ ├── PreDecrementTest.java │ │ ├── RangeSizeTest.java │ │ ├── ReturnInstantiatedArrayDirectlyTest.java │ │ ├── NullRefTest.java │ │ └── UseBooleanTest.java └── main │ └── java │ └── com │ └── aparapi │ ├── package-info.java │ ├── opencl │ └── package-info.java │ ├── annotation │ ├── package-info.java │ └── Experimental.java │ ├── exception │ ├── package-info.java │ ├── CompileFailedException.java │ ├── AparapiJNIException.java │ └── QueryFailedException.java │ ├── internal │ ├── tool │ │ └── package-info.java │ ├── annotation │ │ ├── DocMe.java │ │ ├── UsedByJNICode.java │ │ ├── RemoveMe.java │ │ └── Unused.java │ ├── model │ │ ├── Supplier.java │ │ └── CacheEnabler.java │ ├── util │ │ ├── Reflection.java │ │ └── OpenCLUtil.java │ ├── kernel │ │ ├── PreferencesWrapper.java │ │ ├── KernelManagers.java │ │ └── IKernelBarrier.java │ ├── opencl │ │ └── OpenCLMem.java │ └── jni │ │ └── RangeJNI.java │ └── device │ └── IOpenCLDeviceConfigurator.java ├── .editorconfig ├── NOTICE ├── .m2 └── settings.xml ├── codecov.yml ├── .travis └── codacy-install.sh └── CONTRIBUTORS.md /.cz.json: -------------------------------------------------------------------------------- 1 | { "path": "cz-customizable" } 2 | -------------------------------------------------------------------------------- /src/test/resources/squarer.cl: -------------------------------------------------------------------------------- 1 | 2 | __kernel void square( __global float *in, __global float *out){ 3 | const size_t id = get_global_id(0); 4 | out[id] = in[id]*in[id]; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | #unix style line ending 6 | end_of_line = lf 7 | #newline at end of file 8 | insert_final_newline = true 9 | #charset UTF-8 10 | charset = utf-8 11 | #indent using spaces 12 | indent_style = space 13 | #4 spaces per indent 14 | indent_size = 4 15 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 - 2018 Syncleus, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /.m2/settings.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | ossrh.snapshots 6 | ${env.MAVEN_REPO_USER} 7 | ${env.MAVEN_REPO_PASS} 8 | 9 | 10 | ossrh 11 | ${env.MAVEN_REPO_USER} 12 | ${env.MAVEN_REPO_PASS} 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | notify: 3 | require_ci_to_pass: true 4 | comment: 5 | behavior: default 6 | layout: header, diff 7 | require_changes: false 8 | coverage: 9 | precision: 2 10 | range: 11 | - 0.0 12 | - 70.0 13 | round: down 14 | status: 15 | changes: false 16 | patch: true 17 | project: true 18 | notify: 19 | gitter: 20 | default: 21 | url: "https://webhooks.gitter.im/e/361b21c7d531bd2e122c" 22 | threshold: 1% 23 | parsers: 24 | gcov: 25 | branch_detection: 26 | conditional: true 27 | loop: true 28 | macro: false 29 | method: false 30 | javascript: 31 | enable_partials: false 32 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * 18 | */ 19 | package com.aparapi; -------------------------------------------------------------------------------- /src/main/java/com/aparapi/opencl/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * 18 | */ 19 | package com.aparapi.opencl; -------------------------------------------------------------------------------- /src/main/java/com/aparapi/annotation/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * 18 | */ 19 | package com.aparapi.annotation; -------------------------------------------------------------------------------- /src/main/java/com/aparapi/exception/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * 18 | */ 19 | package com.aparapi.exception; -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/tool/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /** 17 | * 18 | */ 19 | package com.aparapi.internal.tool; -------------------------------------------------------------------------------- /.travis/codacy-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | if [[ ${TRAVIS_OS_NAME} == "osx" ]]; then 3 | # Xpath doesn't work on OSX, so use a hard-coded version number 4 | latest="4.0.1" 5 | else 6 | # get latest version of codacy reporter from sonatype 7 | latest=$(curl "https://oss.sonatype.org/service/local/repositories/releases/content/com/codacy/codacy-coverage-reporter/maven-metadata.xml" | xpath -e "/metadata/versioning/release/text()") 8 | fi 9 | 10 | echo Downloading latest version $latest of codacy reporter from sonatype 11 | # download laterst assembly jar 12 | mvn dependency:get dependency:copy \ 13 | -DoutputDirectory=$HOME \ 14 | -DoutputAbsoluteArtifactFilename=true \ 15 | -Dmdep.stripVersion=true \ 16 | -DrepoUrl=https://oss.sonatype.org/service/local/repositories/releases/content/ \ 17 | -Dartifact=com.codacy:codacy-coverage-reporter:$latest:jar:assembly 18 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreDecrement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreDecrement { 19 | public void run() { 20 | int i = 123; 21 | boolean result = --i < 123; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/annotation/DocMe.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.annotation; 17 | 18 | /** 19 | * Use this annotation to tag stuff that needs Java Doc added 20 | * 21 | * @author gfrost 22 | */ 23 | public @interface DocMe { 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/model/Supplier.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.model; 17 | 18 | /** 19 | * Substitute of Java8's Supplier interface, used in Java7 backport of caches. 20 | */ 21 | public interface Supplier { 22 | V get(); 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Assign2DIntArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Assign2DIntArray { 19 | int[][] ints = new int[1024][]; 20 | 21 | public void run() { 22 | ints[0][0] = 1; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/annotation/UsedByJNICode.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.annotation; 17 | 18 | /** 19 | * Be careful changing the name/type of this field as it is referenced from JNI code. 20 | */ 21 | public @interface UsedByJNICode { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IncField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class IncField { 19 | int field = 1024; 20 | 21 | public void run() { 22 | field++; 23 | } 24 | } 25 | /**{Throws{ClassParseException}Throws}**/ 26 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AssignField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class AssignField { 19 | int field = 1024; 20 | 21 | public void run() { 22 | field = 100; 23 | } 24 | } 25 | /**{Throws{ClassParseException}Throws}**/ 26 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/annotation/RemoveMe.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.annotation; 17 | 18 | /** 19 | * Use this annotation to tag fields that we think need to be removed (method/field/var) 20 | * 21 | * @author gfrost 22 | */ 23 | public @interface RemoveMe { 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/EmptyIfBlock.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class EmptyIfBlock { 19 | 20 | public void run() { 21 | int idx = 34; 22 | if(idx < 5) { 23 | } 24 | } 25 | } 26 | /**{Throws{ClassParseException}Throws}**/ 27 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Access2DIntArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Access2DIntArray { 19 | int[][] ints = new int[1024][]; 20 | 21 | public void run() { 22 | int value = ints[0][0]; 23 | } 24 | } 25 | /**{Throws{ClassParseException}Throws}**/ 26 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/StaticFieldStore.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class StaticFieldStore { 19 | static int foo = 6; 20 | int[] ints = new int[1024]; 21 | 22 | public void run() { 23 | foo = ints[0]; 24 | } 25 | } 26 | /**{Throws{ClassParseException}Throws}**/ 27 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/UsesNew.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class UsesNew { 19 | int[] ints = new int[1024]; 20 | 21 | public void run() { 22 | @SuppressWarnings("unused") int foo = 1; 23 | 24 | ints = new int[128]; 25 | } 26 | } 27 | /**{Throws{ClassParseException}Throws}**/ 28 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/runtime/OriginalKernelManager.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.runtime; 17 | 18 | import com.aparapi.internal.kernel.KernelManager; 19 | 20 | /** 21 | * Provides a way for re-establishing the default Aparapi KernelManager 22 | * @author CoreRasurae 23 | */ 24 | public class OriginalKernelManager extends KernelManager { 25 | } 26 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnIntArrayNew.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnIntArrayNew { 19 | 20 | int[] returnIntArrayNew() { 21 | return new int[1024]; 22 | } 23 | 24 | public void run() { 25 | returnIntArrayNew(); 26 | } 27 | } 28 | /**{Throws{CodeGenException}Throws}**/ 29 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/annotation/Unused.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.annotation; 17 | 18 | /** 19 | * Used to tag unused features (methods/fields) 20 | *

21 | * Do not rely on anything tagged as unused, it will probably be retracted/refactored 22 | * 23 | * @author gfrost 24 | * 25 | */ 26 | public @interface Unused { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnByteArrayNew.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnByteArrayNew { 19 | 20 | byte[] returnByteArrayNew() { 21 | return new byte[1024]; 22 | } 23 | 24 | public void run() { 25 | returnByteArrayNew(); 26 | } 27 | } 28 | /**{Throws{CodeGenException}Throws}**/ 29 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnLongArrayNew.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnLongArrayNew { 19 | 20 | long[] returnLongArrayNew() { 21 | return new long[1024]; 22 | } 23 | 24 | public void run() { 25 | returnLongArrayNew(); 26 | } 27 | } 28 | /**{Throws{CodeGenException}Throws}**/ 29 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/annotation/Experimental.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.annotation; 17 | 18 | /** 19 | * Used to tag experimental features (methods/fields) 20 | *

21 | * Do not rely on anything tagged as experimental, it will probably be retracted/refactored 22 | * 23 | * @author gfrost 24 | * 25 | */ 26 | public @interface Experimental { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncIntField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostIncIntField { 19 | 20 | int _y = 2; 21 | 22 | int incInt(int a) { 23 | return a++; 24 | } 25 | 26 | public void run() { 27 | 28 | incInt(_y++); 29 | 30 | } 31 | } 32 | /**{Throws{ClassParseException}Throws}**/ 33 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnFloatArrayNew.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnFloatArrayNew { 19 | 20 | float[] returnFloatArrayNew() { 21 | return new float[1024]; 22 | } 23 | 24 | public void run() { 25 | returnFloatArrayNew(); 26 | } 27 | } 28 | /**{Throws{CodeGenException}Throws}**/ 29 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnShortArrayNew.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnShortArrayNew { 19 | 20 | short[] returnShortArrayNew() { 21 | return new short[1024]; 22 | } 23 | 24 | public void run() { 25 | returnShortArrayNew(); 26 | } 27 | } 28 | /**{Throws{CodeGenException}Throws}**/ 29 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncIntField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreIncIntField { 19 | 20 | int y = 2; 21 | 22 | int preIncInt(int _a) { 23 | return ++_a; 24 | } 25 | 26 | public void run() { 27 | 28 | preIncInt(++y); 29 | 30 | } 31 | } 32 | /**{Throws{ClassParseException}Throws}**/ 33 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayNew.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnDoubleArrayNew { 19 | 20 | double[] returnDoubleArrayNew() { 21 | return new double[1024]; 22 | } 23 | 24 | public void run() { 25 | returnDoubleArrayNew(); 26 | } 27 | } 28 | /**{Throws{CodeGenException}Throws}**/ 29 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AccessNested2DIntArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class AccessNested2DIntArray { 19 | int[] indices = new int[1024]; 20 | 21 | int[][] ints = new int[1024][]; 22 | 23 | public void run() { 24 | int value = ints[indices[0]][0]; 25 | } 26 | 27 | } 28 | /**{Throws{ClassParseException}Throws}**/ 29 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncByteField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostIncByteField { 19 | 20 | byte z = (byte) 3; 21 | 22 | byte incByte(byte _a) { 23 | return _a++; 24 | } 25 | 26 | public void run() { 27 | 28 | z = incByte(z++); 29 | 30 | } 31 | } 32 | /**{Throws{ClassParseException}Throws}**/ 33 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncByteField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreIncByteField { 19 | 20 | byte z = (byte) 3; 21 | 22 | byte incByte(byte _a) { 23 | return ++_a; 24 | } 25 | 26 | public void run() { 27 | 28 | z = incByte(++z); 29 | 30 | } 31 | } 32 | /**{Throws{ClassParseException}Throws}**/ 33 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnBooleanNewArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnBooleanNewArray { 19 | 20 | boolean[] returnBooleanNewArray() { 21 | 22 | return new boolean[1024]; 23 | } 24 | 25 | public void run() { 26 | returnBooleanNewArray(); 27 | } 28 | } 29 | /**{Throws{CodeGenException}Throws}**/ 30 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AssignAndPassAsParameterSimple.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class AssignAndPassAsParameterSimple { 19 | 20 | void actuallyDoIt(int a) { 21 | 22 | } 23 | 24 | public void run() { 25 | @SuppressWarnings("unused") int z; 26 | actuallyDoIt(z = 1); 27 | } 28 | } 29 | /**{Throws{CodeGenException}Throws}**/ 30 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnLongArrayVar.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnLongArrayVar { 19 | 20 | long[] returnLongArrayVar() { 21 | long[] longs = new long[1024]; 22 | return longs; 23 | } 24 | 25 | public void run() { 26 | 27 | returnLongArrayVar(); 28 | } 29 | } 30 | /**{OpenCL{ 31 | 32 | }OpenCL}**/ 33 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Break.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Break { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | for (int i = 0; i < 10; i++) { 22 | if (i == 5) { 23 | break; 24 | } 25 | pass = true; 26 | } 27 | } 28 | } 29 | /**{Throws{ClassParseException}Throws}**/ 30 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/exception/CompileFailedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.exception; 17 | 18 | import com.aparapi.internal.exception.AparapiException; 19 | 20 | @SuppressWarnings("serial") 21 | public class CompileFailedException extends AparapiException { 22 | 23 | public CompileFailedException(String reason) { 24 | super(reason); 25 | } 26 | 27 | public CompileFailedException(Throwable _t) { 28 | super(_t); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ForEach.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ForEach { 19 | 20 | int out[] = new int[10]; 21 | int in[] = new int[10]; 22 | 23 | public void run() { 24 | int max = Integer.MIN_VALUE; 25 | for (int i : in) { 26 | if (i > max) 27 | max = i; 28 | } 29 | out[0] = max; 30 | } 31 | } 32 | /**{Throws{ClassParseException}Throws}**/ 33 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/EntrypointRecursion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class EntrypointRecursion extends Kernel { 21 | 22 | int[] values = new int[128]; 23 | 24 | public void run() { 25 | int id = getGlobalId(); 26 | 27 | values[id]++; 28 | 29 | if (values[id] < 20) { 30 | run(); 31 | } 32 | } 33 | 34 | } 35 | /**{Throws{ClassParseException}Throws}**/ 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/CallObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class CallObject extends Kernel { 21 | Dummy dummy = new Dummy(); 22 | 23 | ; 24 | int out[] = new int[2]; 25 | 26 | public void run() { 27 | out[0] = dummy.foo(); 28 | } 29 | 30 | static class Dummy { 31 | public int foo() { 32 | return 42; 33 | } 34 | } 35 | } 36 | /**{Throws{ClassParseException}Throws}**/ 37 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/FusedMultiplyAdd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class FusedMultiplyAdd extends Kernel { 21 | public void run() { 22 | double d1 = 123.0, d2 = 0.456, d3 = 789.0; 23 | float f1 = 123.0f, f2 = 0.456f, f3 = 789.0f; 24 | 25 | @SuppressWarnings("unused") boolean pass = true; 26 | if ((fma(d1, d2, d3) != 845.088) || (fma(f1, f2, f3) != 845.088f)) 27 | pass = false; 28 | } 29 | } -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/UseObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class UseObject extends Kernel { 21 | Dummy dummy = new Dummy(); 22 | 23 | ; 24 | int out[] = new int[2]; 25 | int plainInt = -1; 26 | 27 | public void run() { 28 | out[0] = dummy.n; 29 | out[1] = plainInt; 30 | } 31 | 32 | class Dummy { 33 | public int n; 34 | } 35 | 36 | } 37 | /**{Throws{ClassParseException}Throws}**/ 38 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/DirectRecursion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class DirectRecursion extends Kernel { 21 | 22 | int intout[] = new int[1]; 23 | 24 | public void run() { 25 | intout[0] = fact(10); 26 | @SuppressWarnings("unused") boolean pass = false; 27 | } 28 | 29 | int fact(int n) { 30 | return (n <= 1 ? n : n * fact(n - 1)); 31 | } 32 | 33 | } 34 | /**{Throws{ClassParseException}Throws}**/ 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/runtime/PreDecrementTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.runtime; 17 | 18 | import com.aparapi.Kernel; 19 | import org.junit.Test; 20 | 21 | 22 | public class PreDecrementTest { 23 | @Test 24 | public void test() { 25 | PreDecrement kernel = new PreDecrement(); 26 | kernel.execute(1); 27 | } 28 | 29 | public class PreDecrement extends Kernel { 30 | public void run() { 31 | int idx = 34; 32 | if(idx < 5) { 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ForBreak.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ForBreak { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | for (int i = 0; i > 2 && i < 10; i++) { 22 | pass = false; 23 | if (i == 5 || i == 6) { 24 | if (i == 5) { 25 | pass = true; 26 | break; 27 | } 28 | } 29 | } 30 | 31 | } 32 | } 33 | /**{Throws{ClassParseException}Throws}**/ 34 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ObjectRefCopy.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class ObjectRefCopy extends Kernel { 21 | 22 | final int size = 8; 23 | 24 | ; 25 | DummyOOA dummy[] = new DummyOOA[size]; 26 | 27 | public void run() { 28 | int myId = getGlobalId(); 29 | dummy[myId] = dummy[myId + 1]; 30 | } 31 | 32 | final static class DummyOOA { 33 | int mem; 34 | 35 | float floatField; 36 | } 37 | } 38 | 39 | /**{Throws{ClassParseException}Throws}**/ 40 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Sequence.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Sequence { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | 22 | } 23 | } 24 | /**{OpenCL{ 25 | typedef struct This_s{ 26 | int passid; 27 | }This; 28 | int get_pass_id(This *this){ 29 | return this->passid; 30 | } 31 | __kernel void run( 32 | int passid 33 | ){ 34 | This thisStruct; 35 | This* this=&thisStruct; 36 | this->passid = passid; 37 | { 38 | char pass = 0; 39 | return; 40 | } 41 | } 42 | }OpenCL}**/ 43 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/WideInc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class WideInc { 19 | 20 | public void run() { 21 | int value = 0; 22 | value += 128; 23 | } 24 | } 25 | 26 | /**{OpenCL{ 27 | typedef struct This_s{ 28 | int passid; 29 | }This; 30 | int get_pass_id(This *this){ 31 | return this->passid; 32 | } 33 | __kernel void run( 34 | int passid 35 | ){ 36 | This thisStruct; 37 | This* this=&thisStruct; 38 | this->passid = passid; 39 | { 40 | int value = 0; 41 | value+=128; 42 | return; 43 | } 44 | } 45 | }OpenCL}**/ 46 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Interface.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Interface { 19 | 20 | double out[] = new double[1]; 21 | Operator sa = new SimpleAdder(); 22 | 23 | public void run() { 24 | out[0] = sa.operate(0.0); 25 | } 26 | 27 | public interface Operator { 28 | public double operate(double d); 29 | } 30 | 31 | public class SimpleAdder implements Operator { 32 | public double operate(double d) { 33 | return d + 1.0; 34 | } 35 | } 36 | } 37 | /**{Throws{ClassParseException}Throws}**/ 38 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/EmptyWhileWithInc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class EmptyWhileWithInc { 19 | public void run() { 20 | int x = 0; 21 | while (x++ < 10) { 22 | } 23 | } 24 | } 25 | /**{OpenCL{ 26 | typedef struct This_s{ 27 | int passid; 28 | }This; 29 | int get_pass_id(This *this){ 30 | return this->passid; 31 | } 32 | __kernel void run( 33 | int passid 34 | ){ 35 | This thisStruct; 36 | This* this=&thisStruct; 37 | this->passid = passid; 38 | { 39 | for (int x = 0; x++<10;){} 40 | return; 41 | } 42 | } 43 | }OpenCL}**/ 44 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncLocalStandalone.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostIncLocalStandalone { 19 | 20 | public void run() { 21 | 22 | int i = 0; 23 | i++; 24 | 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | int passid 38 | ){ 39 | This thisStruct; 40 | This* this=&thisStruct; 41 | this->passid = passid; 42 | { 43 | int i = 0; 44 | i++; 45 | return; 46 | } 47 | } 48 | }OpenCL}**/ 49 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncLocalStandalone.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreIncLocalStandalone { 19 | 20 | public void run() { 21 | 22 | int i = 0; 23 | ++i; 24 | 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | int passid 38 | ){ 39 | This thisStruct; 40 | This* this=&thisStruct; 41 | this->passid = passid; 42 | { 43 | int i = 0; 44 | i++; 45 | return; 46 | } 47 | } 48 | }OpenCL}**/ 49 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ForAsFirst.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ForAsFirst { 19 | 20 | public void run() { 21 | 22 | for (int i = 0; i < 1; i++) { 23 | 24 | } 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | int passid 38 | ){ 39 | This thisStruct; 40 | This* this=&thisStruct; 41 | this->passid = passid; 42 | { 43 | for (int i = 0; i<1; i++){ 44 | } 45 | return; 46 | } 47 | } 48 | }OpenCL}**/ 49 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/WhileEmptyLoop.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class WhileEmptyLoop { 19 | public void run() { 20 | int x = 10; 21 | while (x-- != 0) { 22 | } 23 | } 24 | } 25 | /**{OpenCL{ 26 | typedef struct This_s{ 27 | 28 | int passid; 29 | }This; 30 | int get_pass_id(This *this){ 31 | return this->passid; 32 | } 33 | 34 | __kernel void run( 35 | int passid 36 | ){ 37 | This thisStruct; 38 | This* this=&thisStruct; 39 | this->passid = passid; 40 | { 41 | for (int x = 10; x--!=0;){} 42 | return; 43 | } 44 | } 45 | }OpenCL}**/ 46 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/WhileWithoutMutator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class WhileWithoutMutator { 19 | public void run() { 20 | int x = 0; 21 | while (x != 0) { 22 | } 23 | } 24 | } 25 | /**{OpenCL{ 26 | typedef struct This_s{ 27 | int passid; 28 | }This; 29 | int get_pass_id(This *this){ 30 | return this->passid; 31 | } 32 | 33 | __kernel void run( 34 | int passid 35 | ){ 36 | This thisStruct; 37 | This* this=&thisStruct; 38 | this->passid = passid; 39 | { 40 | int x = 0; 41 | for (; x!=0;){} 42 | return; 43 | } 44 | } 45 | }OpenCL}**/ 46 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/model/CacheEnabler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.model; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class CacheEnabler{ 21 | private static volatile boolean cachesEnabled = true; 22 | 23 | public static void setCachesEnabled(boolean cachesEnabled) { 24 | if (CacheEnabler.cachesEnabled != cachesEnabled) { 25 | Kernel.invalidateCaches(); 26 | ClassModel.invalidateCaches(); 27 | } 28 | 29 | CacheEnabler.cachesEnabled = cachesEnabled; 30 | } 31 | 32 | public static boolean areCachesEnabled() { 33 | return cachesEnabled; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/VarargsForEach.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class VarargsForEach { 19 | int out[] = new int[1]; 20 | 21 | public static int max(int... values) { 22 | if (values.length == 0) { 23 | return 0; 24 | } 25 | 26 | int max = Integer.MIN_VALUE; 27 | for (int i : values) { 28 | if (i > max) 29 | max = i; 30 | } 31 | return max; 32 | } 33 | 34 | public void run() { 35 | out[0] = max(1, 4, 5, 9, 3); 36 | } 37 | 38 | } 39 | /**{Throws{ClassParseException}Throws}**/ 40 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IndirectRecursion.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class IndirectRecursion extends Kernel { 21 | 22 | int intout[] = new int[1]; 23 | 24 | public void run() { 25 | intout[0] = foo(10); 26 | @SuppressWarnings("unused") boolean pass = false; 27 | } 28 | 29 | int foo(int n) { 30 | if (n > 0) { 31 | return bar(n); 32 | } 33 | return -1; 34 | } 35 | 36 | int bar(int n) { 37 | return foo(--n); 38 | } 39 | 40 | } 41 | /**{Throws{ClassParseException}Throws}**/ 42 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ObjectWithinObject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class ObjectWithinObject extends Kernel { 21 | 22 | final int size = 8; 23 | 24 | ; 25 | DummyOOA dummy[] = new DummyOOA[size]; 26 | 27 | public void run() { 28 | int myId = getGlobalId(); 29 | dummy[myId].mem = dummy[myId].next.mem + 4; 30 | } 31 | 32 | final static class DummyOOA { 33 | int mem; 34 | 35 | float floatField; 36 | 37 | DummyOOA next; 38 | 39 | } 40 | } 41 | 42 | /**{Throws{ClassParseException}Throws}**/ 43 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/util/Reflection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.util; 17 | 18 | /** 19 | * Created by Barney on 03/09/2015. 20 | */ 21 | public class Reflection { 22 | 23 | /** Avoids getting dumb empty names for anonymous inners. */ 24 | public static String getSimpleName(Class klass) { 25 | String simpleName = klass.getSimpleName(); 26 | if (simpleName.isEmpty()) { 27 | String fullName = klass.getName(); 28 | int index = fullName.lastIndexOf('.'); 29 | simpleName = (index < 0) ? fullName : fullName.substring(index + 1); 30 | } 31 | return simpleName; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/CallGetPassId.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class CallGetPassId extends Kernel { 21 | public void run() { 22 | int thePassId = getPassId(); 23 | } 24 | 25 | } 26 | /**{OpenCL{ 27 | 28 | typedef struct This_s{ 29 | int passid; 30 | }This; 31 | int get_pass_id(This *this){ 32 | return this->passid; 33 | } 34 | __kernel void run( 35 | int passid 36 | ){ 37 | This thisStruct; 38 | This* this=&thisStruct; 39 | this->passid = passid; 40 | { 41 | int thePassId = get_pass_id(this); 42 | return; 43 | } 44 | } 45 | 46 | }OpenCL}**/ 47 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/VarargsSimple.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class VarargsSimple { 19 | int out[] = new int[1]; 20 | 21 | public static int max(int... values) { 22 | if (values.length == 0) { 23 | return 0; 24 | } 25 | 26 | int max = Integer.MIN_VALUE; 27 | for (int i = 0; i < values.length; i++) { 28 | if (values[i] > max) 29 | max = i; 30 | } 31 | return max; 32 | } 33 | 34 | public void run() { 35 | out[0] = max(1, 4, 5, 9, 3); 36 | } 37 | 38 | } 39 | /**{Throws{ClassParseException}Throws}**/ 40 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/util/OpenCLUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.util; 17 | 18 | import java.util.List; 19 | 20 | import com.aparapi.internal.opencl.OpenCLPlatform; 21 | 22 | /** 23 | * This utility class encapsulates the necessary actions required to query underlying OpenCL information 24 | */ 25 | public class OpenCLUtil{ 26 | 27 | /** 28 | * Retrieve a list of available OpenCL Platforms 29 | * 30 | * @return Available OpenCL Platforms 31 | */ 32 | public static List getOpenCLPlatforms() { 33 | final OpenCLPlatform ocp = new OpenCLPlatform(); 34 | return ocp.getOpenCLPlatforms(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/kernel/PreferencesWrapper.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.kernel; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class PreferencesWrapper { 21 | 22 | private Class klass; 23 | private KernelPreferences preferences; 24 | 25 | public PreferencesWrapper(Class klass, KernelPreferences preferences) { 26 | super(); 27 | this.klass = klass; 28 | this.preferences = preferences; 29 | } 30 | 31 | public Class getKernelClass() { 32 | return klass; 33 | } 34 | 35 | public KernelPreferences getPreferences() { 36 | return preferences; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/NaN.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class NaN extends Kernel { 21 | @Override 22 | public void run() { 23 | double d = 1.0E-10; 24 | } 25 | } 26 | /**{OpenCL{ 27 | #pragma OPENCL EXTENSION cl_khr_fp64 : enable 28 | 29 | typedef struct This_s{ 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | double d = 1.0E-10; 45 | return; 46 | } 47 | } 48 | }OpenCL}**/ 49 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/CharArrayField.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class CharArrayField { 19 | char out[] = new char[1]; 20 | 21 | public void run() { 22 | out[0] = 0; 23 | } 24 | } 25 | 26 | /**{OpenCL{ 27 | typedef struct This_s{ 28 | __global unsigned short *out; 29 | int passid; 30 | }This; 31 | int get_pass_id(This *this){ 32 | return this->passid; 33 | } 34 | __kernel void run( 35 | __global unsigned short *out, 36 | int passid 37 | ){ 38 | This thisStruct; 39 | This* this=&thisStruct; 40 | this->out = out; 41 | this->passid = passid; 42 | { 43 | this->out[0] = 0; 44 | return; 45 | } 46 | } 47 | }OpenCL}**/ 48 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostDecPostInc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostDecPostInc { 19 | 20 | public void run() { 21 | int i = 0; 22 | @SuppressWarnings("unused") int result = 0; 23 | result = i-- + i++; 24 | 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | int passid 38 | ){ 39 | This thisStruct; 40 | This* this=&thisStruct; 41 | this->passid = passid; 42 | { 43 | int i = 0; 44 | int result = 0; 45 | result = i-- + i++; 46 | return; 47 | } 48 | } 49 | }OpenCL}**/ 50 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreDecPostInc.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreDecPostInc { 19 | 20 | public void run() { 21 | int i = 0; 22 | @SuppressWarnings("unused") int result = 0; 23 | result = --i + i++; 24 | 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | int passid 38 | ){ 39 | This thisStruct; 40 | This* this=&thisStruct; 41 | this->passid = passid; 42 | { 43 | int i = 0; 44 | int result = 0; 45 | i--; 46 | result = i + i++; 47 | return; 48 | } 49 | } 50 | }OpenCL}**/ 51 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/device/IOpenCLDeviceConfigurator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.device; 17 | 18 | /** 19 | * This interface provides a way for the client application to refine the default devices 20 | * configuration obtained by the underlying OpenCL platforms in a centralized, automated manner.
21 | * 22 | * @author CoreRasurae 23 | */ 24 | public interface IOpenCLDeviceConfigurator { 25 | 26 | /** 27 | * Called for each OpenCL device detected by Aparapi.
28 | * Gives the client application an opportunity to refine the device configuration parameters. 29 | * 30 | * @param device the OpenCL device to be configured 31 | */ 32 | public void configure(OpenCLDevice device); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/For.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class For { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | for (int i = 0; i < 10; i++) { 22 | pass = true; 23 | } 24 | 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | int passid; 30 | }This; 31 | int get_pass_id(This *this){ 32 | return this->passid; 33 | } 34 | __kernel void run( 35 | int passid 36 | ){ 37 | This thisStruct; 38 | This* this=&thisStruct; 39 | this->passid = passid; 40 | { 41 | char pass = 0; 42 | for (int i = 0; i<10; i++){ 43 | pass = 1; 44 | } 45 | return; 46 | } 47 | } 48 | }OpenCL}**/ 49 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/exception/AparapiJNIException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.exception; 17 | 18 | /** 19 | * This exception is thrown by underlying Aparapi JNI native code when the JNI call fails 20 | * 21 | * @author CoreRasurae 22 | */ 23 | public class AparapiJNIException extends RuntimeException { 24 | 25 | public AparapiJNIException(String message) { 26 | super(message); 27 | } 28 | 29 | public AparapiJNIException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | 33 | public AparapiJNIException(String message, Throwable cause, boolean enableSuppression, 34 | boolean writableStackTrace) { 35 | super(message, cause, enableSuppression, writableStackTrace); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/exception/QueryFailedException.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.exception; 17 | 18 | import com.aparapi.internal.exception.AparapiException; 19 | 20 | /** 21 | * This exception is thrown when an unexpected behavior occurs while querying the OpenCL platform. 22 | * 23 | * @author CoreRasurae 24 | */ 25 | @SuppressWarnings("serial") 26 | public class QueryFailedException extends AparapiException { 27 | 28 | public QueryFailedException(String reason) { 29 | super(reason); 30 | } 31 | 32 | public QueryFailedException(String reason, Throwable _t) { 33 | super(reason, _t); 34 | } 35 | 36 | public QueryFailedException(Throwable _t) { 37 | super(_t); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/runtime/RangeSizeTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.runtime; 17 | 18 | import com.aparapi.Range; 19 | import org.junit.Test; 20 | 21 | import static org.junit.Assert.assertTrue; 22 | 23 | public class RangeSizeTest { 24 | 25 | @Test 26 | public void test384x384() { 27 | Range range = Range.create2D(384, 384); 28 | assertTrue("Range > max work size", range.getLocalSize(0) * range.getLocalSize(1) <= range.getWorkGroupSize()); 29 | } 30 | 31 | @Test 32 | public void test384x320() { 33 | Range range = Range.create2D(384, 320); 34 | assertTrue("Range > max work size", range.getLocalSize(0) * range.getLocalSize(1) <= range.getWorkGroupSize()); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/opencl/OpenCLMem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.opencl; 17 | 18 | public class OpenCLMem{ 19 | 20 | public final static int MEM_DIRTY_BIT = 1 << 0x00F; 21 | 22 | public final static int MEM_COPY_BIT = 1 << 0x010; 23 | 24 | public final static int MEM_ENQUEUED_BIT = 1 << 0x011; 25 | 26 | public long bits; // dirty, copy, enqueued 27 | 28 | public int sizeInBytes; 29 | 30 | public long memId; 31 | 32 | public long address; 33 | 34 | public Object instance; 35 | 36 | public OpenCLProgram program; 37 | 38 | //Dummy JNI method just to ensure that above definition are generated for aparapi-native with newer Java > 8 compilers 39 | private native void dummyJNI(); 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/TernaryNested.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class TernaryNested { 19 | public void run() { 20 | boolean a = false, b = false, c = false; 21 | @SuppressWarnings("unused") int count = a ? b ? 1 : 2 : c ? 3 : 4; 22 | } 23 | } 24 | /**{OpenCL{ 25 | typedef struct This_s{ 26 | int passid; 27 | }This; 28 | int get_pass_id(This *this){ 29 | return this->passid; 30 | 31 | } 32 | __kernel void run( 33 | int passid 34 | ){ 35 | This thisStruct; 36 | This* this=&thisStruct; 37 | this->passid = passid; 38 | { 39 | char a = 0; 40 | char b = 0; 41 | char c = 0; 42 | int count = (a!=0)?(b!=0)?1:2:(c!=0)?3:4; 43 | return; 44 | } 45 | } 46 | }OpenCL}**/ 47 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostDecLocal.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostDecLocal { 19 | 20 | public void run() { 21 | @SuppressWarnings("unused") boolean pass = false; 22 | int i = 0; 23 | if (i-- == 0) 24 | pass = true; 25 | 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | char pass = 0; 45 | int i = 0; 46 | if (i--==0){ 47 | pass = 1; 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncLocal.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostIncLocal { 19 | 20 | public void run() { 21 | @SuppressWarnings("unused") boolean pass = false; 22 | int i = 0; 23 | if (i++ == 0) 24 | pass = true; 25 | 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | char pass = 0; 45 | int i = 0; 46 | if (i++==0){ 47 | pass = 1; 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ForAnd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ForAnd { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | for (int i = 0; i > 2 && i < 10; i++) { 22 | pass = true; 23 | } 24 | 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | int passid 38 | ){ 39 | This thisStruct; 40 | This* this=&thisStruct; 41 | this->passid = passid; 42 | { 43 | char pass = 0; 44 | for (int i = 0; i>2 && i<10; i++){ 45 | pass = 1; 46 | } 47 | return; 48 | } 49 | } 50 | }OpenCL}**/ 51 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncLocal.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreIncLocal { 19 | 20 | public void run() { 21 | @SuppressWarnings("unused") boolean pass = false; 22 | int i = 0; 23 | if (++i == 1) 24 | pass = true; 25 | 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | char pass = 0; 45 | int i = 0; 46 | i++; 47 | if (i==1){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /CONTRIBUTORS.md: -------------------------------------------------------------------------------- 1 | # Contributors 2 | 3 | * Jeffrey Phillips Freeman 4 | * Gary Frost 5 | * Nicholas Wright - https://github.com/seeker 6 | * Veselin Yordanov 7 | * Automenta - https://github.com/automenta 8 | * Joergen Lundgren 9 | * Florian Roesler 10 | * Denis Demidov 11 | * Jakub Szuppe 12 | * Kyle Lutz 13 | * George Vinokhodov 14 | * Witold Bolt 15 | * Kenneth Skovhede 16 | * Ryan LaMothe 17 | * Oliver Coleman 18 | * Steven Libby 19 | * Paul Miner 20 | * Lorenzo Gallucci 21 | * Fernando Marino` 22 | * AMD Corporation 23 | * Dmitriy Shabanov 24 | * Toon Baeyens 25 | * Luis Mendes 26 | * Saurabh Rawat 27 | 28 | # Details 29 | 30 | Below are some of the specific details of various contributions. 31 | 32 | * Jeffrey Phillips Freeman has acted as Lead Developer, daily contributor, and Project Owner since 2016 to present. 33 | * AMD Corporation for being the founder of the project and contributing most of the code that originally got the project off the ground 34 | * Luis Mendes - For being a core maintainer on the project from 2018 to present 35 | * Gary Frost - For being the founding developer of the project while working for AMD 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/UsesThrow.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class UsesThrow { 19 | int[] ints = new int[1024]; 20 | 21 | int doIt(int a) throws Exception { 22 | if (a < 0) { 23 | throw new Exception("Zoinks!"); 24 | } 25 | return (int) (((int) 1) - a); 26 | } 27 | 28 | public void run() { 29 | @SuppressWarnings("unused") int foo = 1; 30 | try { 31 | for (int i = 0; i < 1024; i++) { 32 | if (i % 2 == 0) { 33 | ints[i] = doIt(i); 34 | } 35 | } 36 | } catch (Exception e) { 37 | // nothing 38 | } 39 | } 40 | } 41 | /**{Throws{ClassParseException}Throws}**/ 42 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/EarlyReturn.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class EarlyReturn { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | int i = 0; 22 | if ((i % 2) == 0) { 23 | return; 24 | } 25 | i++; 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | __kernel void run( 37 | int passid 38 | ){ 39 | This thisStruct; 40 | This* this=&thisStruct; 41 | this->passid = passid; 42 | { 43 | char pass = 0; 44 | int i=0; 45 | if ((i%2)==0){ 46 | return; 47 | } 48 | i++; 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncLocalTwice.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostIncLocalTwice { 19 | 20 | public void run() { 21 | @SuppressWarnings("unused") boolean pass = false; 22 | int i = 0; 23 | if (i++ + i++ == 1) 24 | pass = true; 25 | 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | char pass = 0; 45 | int i = 0; 46 | if ((i++ + i++)==1){ 47 | pass = 1; 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/While.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class While { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | int i = 0; 22 | while (i < 10) { 23 | pass = true; 24 | i++; 25 | } 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | char pass = 0; 46 | int i = 0; 47 | for (; i<10; i++){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncArrayIndexAndElement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostIncArrayIndexAndElement { 19 | 20 | int array[] = new int[4]; 21 | 22 | public void run() { 23 | int i = 0; 24 | array[i++]++; 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | __global int *array; 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | __global int *array, 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->array = array; 43 | this->passid = passid; 44 | { 45 | int i = 0; 46 | this->array[i++] = this->array[i] + 1; 47 | return; 48 | } 49 | } 50 | }OpenCL}**/ 51 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreDecArrayIndexAndElement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreDecArrayIndexAndElement { 19 | 20 | int array[] = new int[4]; 21 | 22 | public void run() { 23 | int i = 0; 24 | --array[--i]; 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | __global int *array; 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | __global int *array, 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->array = array; 43 | this->passid = passid; 44 | { 45 | int i = 0; 46 | this->array[--i] = this->array[i] - 1; 47 | return; 48 | } 49 | } 50 | }OpenCL}**/ 51 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncArrayIndexAndElement.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreIncArrayIndexAndElement { 19 | 20 | int array[] = new int[4]; 21 | 22 | public void run() { 23 | int i = 0; 24 | ++array[++i]; 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | __global int *array; 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | __global int *array, 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->array = array; 43 | this->passid = passid; 44 | { 45 | int i = 0; 46 | this->array[++i] = this->array[i] + 1; 47 | return; 48 | } 49 | } 50 | }OpenCL}**/ 51 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncLocalTwice.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreIncLocalTwice { 19 | 20 | public void run() { 21 | @SuppressWarnings("unused") boolean pass = false; 22 | int i = 0; 23 | if (++i + ++i == 3) 24 | pass = true; 25 | 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | char pass = 0; 45 | int i = 0; 46 | i++; 47 | if ((i++ + i)==3){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/SynchronizedMethods.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class SynchronizedMethods { 19 | int[] ints = new int[1024]; 20 | 21 | synchronized int doIt(int a) { 22 | return (int) (((int) 1) - a); 23 | } 24 | 25 | int doIt2(int a) { 26 | return (int) (((int) 1) - a); 27 | } 28 | 29 | public void run() { 30 | int foo = 1; 31 | for (int i = 0; i < 1024; i++) { 32 | if (i % 2 == 0) { 33 | ints[i] = doIt(i); 34 | } else { 35 | synchronized (this) { 36 | ints[i] = doIt2(foo); 37 | } 38 | } 39 | } 40 | } 41 | } 42 | /**{Throws{ClassParseException}Throws}**/ 43 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ArrayTortureIssue35.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ArrayTortureIssue35 { 19 | int[] a = new int[1]; 20 | 21 | int[] b = new int[1]; 22 | 23 | public void run() { 24 | a[b[0]++] = 1; 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | __global int *a; 30 | __global int *b; 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | __global int *a, 39 | __global int *b, 40 | int passid 41 | ){ 42 | This thisStruct; 43 | This* this=&thisStruct; 44 | this->a = a; 45 | this->b = b; 46 | this->passid = passid; 47 | { 48 | this->a[this->b[0]++] = 1; 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/MultipleAssign.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class MultipleAssign { 19 | 20 | public void run() { 21 | @SuppressWarnings("unused") int a = 0; 22 | @SuppressWarnings("unused") int b = 0; 23 | @SuppressWarnings("unused") int c = 0; 24 | a = b = c = 4; 25 | 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | int a = 0; 45 | int b = 0; 46 | int c = 0; 47 | a = b = c = 4; 48 | return; 49 | } 50 | } 51 | }OpenCL}**/ 52 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/DoWhile.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class DoWhile { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | int i = 0; 22 | do { 23 | pass = true; 24 | i++; 25 | } while (i < 10); 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | char pass = 0; 45 | int i = 0; 46 | do{ 47 | pass = 1; 48 | i++; 49 | }while (i<10); 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/If.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class If { 19 | public void run() { 20 | int testValue = 10; 21 | @SuppressWarnings("unused") boolean pass = false; 22 | 23 | if (testValue % 4 == 0) { 24 | pass = true; 25 | } 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | int testValue = 10; 46 | char pass = 0; 47 | if ( (testValue % 4) == 0){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/NonNullCheck.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class NonNullCheck { 19 | int[] ints = new int[1024]; 20 | 21 | public void run() { 22 | if (ints != null) { 23 | int value = ints[0]; 24 | } 25 | 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | __global int *ints; 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | __global int *ints, 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->ints = ints; 44 | this->passid = passid; 45 | { 46 | if (this->ints != NULL){ 47 | int value = this->ints[0]; 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/NewLocalArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class NewLocalArray { 19 | 20 | int array[] = new int[4]; 21 | 22 | public void run() { 23 | @SuppressWarnings("unused") boolean pass = false; 24 | int i = 0; 25 | if (i++ == 0) 26 | pass = true; 27 | 28 | } 29 | } 30 | /**{OpenCL{ 31 | typedef struct This_s{ 32 | 33 | int passid; 34 | }This; 35 | int get_pass_id(This *this){ 36 | return this->passid; 37 | } 38 | 39 | __kernel void run( 40 | int passid 41 | ){ 42 | This thisStruct; 43 | This* this=&thisStruct; 44 | this->passid = passid; 45 | { 46 | char pass = 0; 47 | int i = 0; 48 | if (i++==0){ 49 | pass = 1; 50 | } 51 | return; 52 | } 53 | } 54 | }OpenCL}**/ 55 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/kernel/KernelManagers.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.kernel; 17 | 18 | import com.aparapi.device.*; 19 | 20 | import java.util.*; 21 | 22 | /** 23 | * KernelManager instances useful for debugging. 24 | */ 25 | public class KernelManagers { 26 | 27 | public static final KernelManager JTP_ONLY = new KernelManager() { 28 | 29 | @Override 30 | protected List getPreferredDeviceTypes() { 31 | return Collections.singletonList(Device.TYPE.JTP); 32 | } 33 | }; 34 | 35 | public static final KernelManager SEQUENTIAL_ONLY = new KernelManager() { 36 | 37 | @Override 38 | protected List getPreferredDeviceTypes() { 39 | return Collections.singletonList(Device.TYPE.SEQ); 40 | } 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AccessIntArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class AccessIntArray { 19 | int[] ints = new int[1024]; 20 | 21 | public void run() { 22 | for (int i = 0; i < 1024; i++) { 23 | ints[i] = 1; 24 | } 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | __global int *ints; 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | __global int *ints, 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->ints = ints; 44 | this->passid = passid; 45 | { 46 | for (int i = 0; i<1024; i++){ 47 | this->ints[i] = 1; 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/BreakTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class BreakTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void BreakTest() { 27 | test(com.aparapi.codegen.test.Break.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void BreakTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.Break.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Ex.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Ex { 19 | public void run() { 20 | int total = 0; 21 | for (int i = 0; i < 100; i++) { 22 | if (i % 10 == 0 && i % 4 == 0) { 23 | total++; 24 | } 25 | } 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | int passid; 31 | }This; 32 | int get_pass_id(This *this){ 33 | return this->passid; 34 | } 35 | 36 | __kernel void run( 37 | int passid 38 | ){ 39 | This thisStruct; 40 | This* this=&thisStruct; 41 | this->passid = passid; 42 | { 43 | int total = 0; 44 | for (int i = 0; i<100; i++){ 45 | if ((i % 10)==0 && (i % 4)==0){ 46 | total++; 47 | } 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncInt.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PostIncInt { 19 | 20 | int foo(int a) { 21 | return a; 22 | } 23 | 24 | public void run() { 25 | int y = 2; 26 | foo(y++); 27 | 28 | } 29 | } 30 | /**{OpenCL{ 31 | typedef struct This_s{ 32 | 33 | int passid; 34 | }This; 35 | int get_pass_id(This *this){ 36 | return this->passid; 37 | } 38 | 39 | int com_amd_aparapi_test_PostIncInt__foo(This *this, int a){ 40 | return(a); 41 | } 42 | __kernel void run( 43 | int passid 44 | ){ 45 | This thisStruct; 46 | This* this=&thisStruct; 47 | this->passid = passid; 48 | { 49 | int y = 2; 50 | com_amd_aparapi_test_PostIncInt__foo(this,y++); 51 | return; 52 | } 53 | } 54 | }OpenCL}**/ 55 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/FloatParamsSimple.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class FloatParamsSimple { 19 | 20 | void floatParams(float y) { 21 | 22 | } 23 | 24 | public void run() { 25 | 26 | floatParams(0f); 27 | 28 | } 29 | } 30 | /**{OpenCL{ 31 | typedef struct This_s{ 32 | 33 | int passid; 34 | }This; 35 | int get_pass_id(This *this){ 36 | return this->passid; 37 | } 38 | 39 | void com_amd_aparapi_test_FloatParamsSimple__floatParams(This *this, float y){ 40 | return; 41 | } 42 | __kernel void run( 43 | int passid 44 | ){ 45 | This thisStruct; 46 | This* this=&thisStruct; 47 | this->passid = passid; 48 | { 49 | com_amd_aparapi_test_FloatParamsSimple__floatParams(this, 0.0f); 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AccessLongArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class AccessLongArray { 19 | long[] longs = new long[1024]; 20 | 21 | public void run() { 22 | for (int i = 0; i < 1024; i++) { 23 | longs[i] = 1; 24 | } 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | __global long *longs; 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | __global long *longs, 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->longs = longs; 44 | this->passid = passid; 45 | { 46 | for (int i = 0; i<1024; i++){ 47 | this->longs[i] = 1L; 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ClassHasStaticMethodSimple.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ClassHasStaticMethodSimple { 19 | 20 | static void staticMethod() { 21 | 22 | } 23 | 24 | public void run() { 25 | staticMethod(); 26 | 27 | } 28 | } 29 | 30 | /**{OpenCL{ 31 | typedef struct This_s{ 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | void com_amd_aparapi_test_ClassHasStaticMethodSimple__staticMethod(){ 38 | return; 39 | } 40 | __kernel void run( 41 | int passid 42 | ){ 43 | This thisStruct; 44 | This* this=&thisStruct; 45 | this->passid = passid; 46 | { 47 | com_amd_aparapi_test_ClassHasStaticMethodSimple__staticMethod(); 48 | return; 49 | } 50 | } 51 | }OpenCL}**/ 52 | 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ForEachTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class ForEachTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void ForEachTest() { 27 | test(com.aparapi.codegen.test.ForEach.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void ForEachTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.ForEach.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ForIf.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ForIf { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | for (int i = 0; i > 2; i++) { 22 | if (i == 3) { 23 | pass = true; 24 | } 25 | } 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | char pass = 0; 46 | for (int i = 0; i>2; i++){ 47 | if (i==3){ 48 | pass = 1; 49 | } 50 | } 51 | return; 52 | } 53 | } 54 | }OpenCL}**/ 55 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Frem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Frem { 19 | float out[] = new float[10]; 20 | float m; 21 | float n; 22 | 23 | public void run() { 24 | out[0] = m % n; 25 | } 26 | } 27 | 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | __global float *out; 31 | float m; 32 | float n; 33 | int passid; 34 | }This; 35 | int get_pass_id(This *this){ 36 | return this->passid; 37 | } 38 | __kernel void run( 39 | __global float *out, 40 | float m, 41 | float n, 42 | int passid 43 | ){ 44 | This thisStruct; 45 | This* this=&thisStruct; 46 | this->out = out; 47 | this->m = m; 48 | this->n = n; 49 | this->passid = passid; 50 | { 51 | this->out[0] = this->m % this->n; 52 | return; 53 | } 54 | } 55 | }OpenCL}**/ 56 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/LongCompares.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class LongCompares { 19 | public void run() { 20 | 21 | @SuppressWarnings("unused") boolean pass = false; 22 | long l1 = 1L; 23 | long l2 = 1L; 24 | if (l1 > l2) { 25 | pass = true; 26 | } 27 | 28 | } 29 | } 30 | /**{OpenCL{ 31 | typedef struct This_s{ 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | __kernel void run( 38 | int passid 39 | ){ 40 | This thisStruct; 41 | This* this=&thisStruct; 42 | this->passid = passid; 43 | { 44 | char pass = 0; 45 | long l1 = 1L; 46 | long l2 = 1L; 47 | if ((l1 - l2)>0){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/NullCheck.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class NullCheck { 19 | int[] ints = new int[1024]; 20 | 21 | public void run() { 22 | if (ints == null) { 23 | return; 24 | } 25 | int value = ints[0]; 26 | } 27 | } 28 | /**{OpenCL{ 29 | typedef struct This_s{ 30 | __global int *ints; 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | __global int *ints, 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->ints = ints; 44 | this->passid = passid; 45 | { 46 | if (this->ints == NULL){ 47 | return; 48 | } 49 | int value = this->ints[0]; 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ForBreakTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class ForBreakTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void ForBreakTest() { 27 | test(com.aparapi.codegen.test.ForBreak.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void ForBreakTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.ForBreak.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IfAnd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class IfAnd { 19 | public void run() { 20 | int testValue = 10; 21 | @SuppressWarnings("unused") boolean pass = false; 22 | 23 | if (testValue >= 0 && testValue < 100) { 24 | pass = true; 25 | } 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | int testValue = 10; 46 | char pass = 0; 47 | if (testValue>=0 && testValue<100){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IfOr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class IfOr { 19 | public void run() { 20 | int testValue = 10; 21 | @SuppressWarnings("unused") boolean pass = false; 22 | 23 | if (testValue >= 0 || testValue < 100) { 24 | pass = true; 25 | } 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | int testValue = 10; 46 | char pass = 0; 47 | if (testValue>=0 || testValue<100){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IncFieldTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class IncFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void IncFieldTest() { 27 | test(com.aparapi.codegen.test.IncField.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void IncFieldTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.IncField.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/UsesNewTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class UsesNewTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void UsesNewTest() { 28 | test(com.aparapi.codegen.test.UsesNew.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void UsesNewTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.UsesNew.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AccessShortArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class AccessShortArray { 19 | short[] shorts = new short[1024]; 20 | 21 | public void run() { 22 | for (int i = 0; i < 1024; i++) { 23 | shorts[i] = 1; 24 | } 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | __global short *shorts; 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | __global short *shorts, 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->shorts = shorts; 44 | this->passid = passid; 45 | { 46 | for (int i = 0; i<1024; i++){ 47 | this->shorts[i] = 1; 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/CharType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class CharType extends Kernel { 21 | int out[] = new int[1]; 22 | 23 | @Override 24 | public void run() { 25 | final char c = Character.MAX_VALUE; 26 | this.out[0] = c; 27 | } 28 | } 29 | 30 | /**{OpenCL{ 31 | typedef struct This_s{ 32 | __global int *out; 33 | int passid; 34 | }This; 35 | int get_pass_id(This *this){ 36 | return this->passid; 37 | } 38 | __kernel void run( 39 | __global int *out, 40 | int passid 41 | ){ 42 | This thisStruct; 43 | This* this=&thisStruct; 44 | this->out = out; 45 | this->passid = passid; 46 | { 47 | unsigned short c = 65535; 48 | this->out[0] = 65535; 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/InterfaceTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class InterfaceTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void InterfaceTest() { 27 | test(com.aparapi.codegen.test.Interface.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void InterfaceTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.Interface.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AccessFloatArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class AccessFloatArray { 19 | float[] floats = new float[1024]; 20 | 21 | public void run() { 22 | for (int i = 0; i < 1024; i++) { 23 | floats[i] = 1f; 24 | } 25 | } 26 | } 27 | /**{OpenCL{ 28 | typedef struct This_s{ 29 | __global float *floats; 30 | 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | 37 | __kernel void run( 38 | __global float *floats, 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->floats = floats; 44 | this->passid = passid; 45 | { 46 | for (int i = 0; i<1024; i++){ 47 | this->floats[i] = 1.0f; 48 | } 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/CallObjectTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class CallObjectTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void CallObjectTest() { 27 | test(com.aparapi.codegen.test.CallObject.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void CallObjectTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.CallObject.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncInt.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class PreIncInt { 19 | 20 | int preIncInt(int a) { 21 | return a; 22 | } 23 | 24 | public void run() { 25 | 26 | int y = 2; 27 | 28 | preIncInt(++y); 29 | 30 | } 31 | } 32 | /**{OpenCL{ 33 | typedef struct This_s{ 34 | 35 | int passid; 36 | }This; 37 | int get_pass_id(This *this){ 38 | return this->passid; 39 | } 40 | 41 | int com_amd_aparapi_test_PreIncInt__preIncInt(This *this, int a){ 42 | return(a); 43 | } 44 | __kernel void run( 45 | int passid 46 | ){ 47 | This thisStruct; 48 | This* this=&thisStruct; 49 | this->passid = passid; 50 | { 51 | int y = 2; 52 | com_amd_aparapi_test_PreIncInt__preIncInt(this,++y); 53 | return; 54 | } 55 | } 56 | }OpenCL}**/ 57 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/UseObjectTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class UseObjectTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void UseObjectTest() { 28 | test(com.aparapi.codegen.test.UseObject.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void UseObjectTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.UseObject.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/UsesThrowTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class UsesThrowTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void UsesThrowTest() { 28 | test(com.aparapi.codegen.test.UsesThrow.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void UsesThrowTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.UsesThrow.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AssignFieldTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class AssignFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void AssignFieldTest() { 27 | test(com.aparapi.codegen.test.AssignField.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void AssignFieldTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.AssignField.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/If_While_Else.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class If_While_Else { 19 | public void run() { 20 | boolean a = true; 21 | 22 | if (a) { 23 | while (a) { 24 | a = false; 25 | } 26 | } else { 27 | a = true; 28 | 29 | } 30 | 31 | } 32 | } 33 | /**{OpenCL{ 34 | typedef struct This_s{ 35 | 36 | int passid; 37 | }This; 38 | int get_pass_id(This *this){ 39 | return this->passid; 40 | } 41 | 42 | __kernel void run( 43 | int passid 44 | ){ 45 | This thisStruct; 46 | This* this=&thisStruct; 47 | this->passid = passid; 48 | { 49 | char a = 1; 50 | if (a!=0){ 51 | for (; a!=0; a = 0){ 52 | } 53 | } else { 54 | a = 1; 55 | } 56 | return; 57 | } 58 | } 59 | }OpenCL}**/ 60 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnPostIncInt.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnPostIncInt { 19 | 20 | int returnPostIncInt(int value) { 21 | 22 | return value++; 23 | } 24 | 25 | public void run() { 26 | returnPostIncInt(3); 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | int com_amd_aparapi_test_ReturnPostIncInt__returnPostIncInt(This *this, int value){ 37 | return(value++); 38 | } 39 | __kernel void run( 40 | int passid 41 | ){ 42 | This thisStruct; 43 | This* this=&thisStruct; 44 | this->passid = passid; 45 | { 46 | com_amd_aparapi_test_ReturnPostIncInt__returnPostIncInt(this, 3); 47 | return; 48 | } 49 | } 50 | }OpenCL}**/ 51 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnPreIncInt.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class ReturnPreIncInt { 19 | 20 | int returnPreIncInt(int value) { 21 | 22 | return ++value; 23 | } 24 | 25 | public void run() { 26 | returnPreIncInt(3); 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | int passid; 32 | }This; 33 | int get_pass_id(This *this){ 34 | return this->passid; 35 | } 36 | int com_amd_aparapi_test_ReturnPreIncInt__returnPreIncInt(This *this, int value){ 37 | value++; 38 | return(value); 39 | } 40 | __kernel void run( 41 | int passid 42 | ){ 43 | This thisStruct; 44 | This* this=&thisStruct; 45 | this->passid = passid; 46 | { 47 | com_amd_aparapi_test_ReturnPreIncInt__returnPreIncInt(this, 3); 48 | return; 49 | } 50 | } 51 | }OpenCL}**/ 52 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/LongCompare.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.Kernel; 19 | 20 | public class LongCompare extends Kernel { 21 | public void run() { 22 | long n1 = 1; 23 | long n2 = 2; 24 | @SuppressWarnings("unused") boolean pass = false; 25 | if (n2 > n1) 26 | pass = true; 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | long n1 = 1L; 46 | long n2 = 2L; 47 | char pass = 0; 48 | if ((n2 - n1)>0){ 49 | pass = 1; 50 | } 51 | return; 52 | } 53 | } 54 | 55 | }OpenCL}**/ 56 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/VarargsSimpleTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class VarargsSimpleTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void VarargsSimpleTest() { 28 | test(com.aparapi.codegen.test.VarargsSimple.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void VarargsSimpleTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.VarargsSimple.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/runtime/ReturnInstantiatedArrayDirectlyTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.runtime; 17 | 18 | import com.aparapi.Kernel; 19 | import org.junit.Ignore; 20 | import org.junit.Test; 21 | 22 | import java.util.Arrays; 23 | 24 | import static org.junit.Assert.assertArrayEquals; 25 | 26 | 27 | public class ReturnInstantiatedArrayDirectlyTest { 28 | @Test 29 | @Ignore("Knon bug, ignoring until fixed.") 30 | public void test() { 31 | ReturnDoubleArrayNew kernel = new ReturnDoubleArrayNew(); 32 | kernel.execute(1); 33 | } 34 | 35 | public class ReturnDoubleArrayNew extends Kernel { 36 | 37 | double[] returnDoubleArrayNew() { 38 | return new double[1024]; 39 | } 40 | 41 | public void run() { 42 | returnDoubleArrayNew(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/jni/RangeJNI.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.jni; 17 | 18 | import com.aparapi.internal.annotation.UsedByJNICode; 19 | 20 | /** 21 | * This class is intended to be used as a 'proxy' or 'facade' object for Java code to interact with JNI 22 | */ 23 | public abstract class RangeJNI{ 24 | 25 | @UsedByJNICode protected int globalSize_0 = 1; 26 | 27 | @UsedByJNICode protected int localSize_0 = 1; 28 | 29 | @UsedByJNICode protected int globalSize_1 = 1; 30 | 31 | @UsedByJNICode protected int localSize_1 = 1; 32 | 33 | @UsedByJNICode protected int globalSize_2 = 1; 34 | 35 | @UsedByJNICode protected int localSize_2 = 1; 36 | 37 | @UsedByJNICode protected int dims; 38 | 39 | @UsedByJNICode protected boolean valid = true; 40 | 41 | @UsedByJNICode protected boolean localIsDerived = false; 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Continue.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Continue { 19 | public void run() { 20 | @SuppressWarnings("unused") boolean pass = false; 21 | for (int i = 0; i < 10; i++) { 22 | if (i == 5) { 23 | continue; 24 | } 25 | pass = true; 26 | } 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | char pass = 0; 46 | for (int i = 0; i<10; i++){ 47 | if (i==5){ 48 | } else { 49 | pass = 1; 50 | } 51 | } 52 | return; 53 | } 54 | } 55 | }OpenCL}**/ 56 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/DirectRecursionTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class DirectRecursionTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void DirectRecursionTest() { 27 | test(com.aparapi.codegen.test.DirectRecursion.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void DirectRecursionTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.DirectRecursion.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IfAndAnd.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class IfAndAnd { 19 | public void run() { 20 | int testValue = 10; 21 | @SuppressWarnings("unused") boolean pass = false; 22 | 23 | if (testValue >= 0 && testValue < 100 && testValue == 20) { 24 | pass = true; 25 | } 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | int testValue = 10; 46 | char pass = 0; 47 | if (testValue>=0 && testValue<100 && testValue==20){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IfOrOr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class IfOrOr { 19 | public void run() { 20 | int testValue = 10; 21 | @SuppressWarnings("unused") boolean pass = false; 22 | 23 | if (testValue >= 0 || testValue < 100 || testValue == 20) { 24 | pass = true; 25 | } 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | int testValue = 10; 46 | char pass = 0; 47 | if (testValue>=0 || testValue<100 || testValue==20){ 48 | pass = 1; 49 | } 50 | return; 51 | } 52 | } 53 | }OpenCL}**/ 54 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncIntFieldTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class PreIncIntFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void PreIncIntFieldTest() { 28 | test(com.aparapi.codegen.test.PreIncIntField.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void PreIncIntFieldTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.PreIncIntField.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/VarargsForEachTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class VarargsForEachTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void VarargsForEachTest() { 28 | test(com.aparapi.codegen.test.VarargsForEach.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void VarargsForEachTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.VarargsForEach.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/aparapi/internal/kernel/IKernelBarrier.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.internal.kernel; 17 | 18 | import java.util.concurrent.ForkJoinPool.ManagedBlocker; 19 | 20 | /** 21 | * Provides the interface for Aparapi Kernel barriers. 22 | * 23 | * @author CoreRasurae 24 | */ 25 | public interface IKernelBarrier extends ManagedBlocker { 26 | /** 27 | * Cancels the barrier. 28 | * 29 | * All threads that may be waiting for the barrier are released and barrier is permanently disabled. 30 | */ 31 | public void cancelBarrier(); 32 | 33 | /** 34 | * Breaks the barrier. 35 | * 36 | * All threads that may be waiting for the barrier are released and will throw {@link com.aparapi.exception.AparapiBrokenBarrierException}. 37 | * @param t the Throwable causing the barrier to break. 38 | */ 39 | public void breakBarrier(Throwable e); 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncIntFieldTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class PostIncIntFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void PostIncIntFieldTest() { 28 | test(com.aparapi.codegen.test.PostIncIntField.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void PostIncIntFieldTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.PostIncIntField.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PreIncByteFieldTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class PreIncByteFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void PreIncByteFieldTest() { 28 | test(com.aparapi.codegen.test.PreIncByteField.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void PreIncByteFieldTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.PreIncByteField.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/FirstAssignInExpression.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class FirstAssignInExpression { 19 | 20 | int y = 2; 21 | 22 | void func(int _arg) { 23 | // nada 24 | } 25 | 26 | public void run() { 27 | int value = 1; 28 | @SuppressWarnings("unused") int result; 29 | func(result = value); 30 | 31 | } 32 | } 33 | /**{OpenCL{ 34 | typedef struct This_s{ 35 | 36 | int passid; 37 | }This; 38 | int get_pass_id(This *this){ 39 | return this->passid; 40 | } 41 | 42 | void func(This *this, int _arg){ 43 | return; 44 | } 45 | __kernel void run( 46 | int passid 47 | ){ 48 | This thisStruct; 49 | This* this=&thisStruct; 50 | this->passid = passid; 51 | { 52 | int result; 53 | func(this, result = 0); 54 | return; 55 | } 56 | } 57 | }OpenCL}**/ 58 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Loops.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Loops { 19 | public void run() { 20 | int sum = 0; 21 | 22 | for (int i = 0; i < 100; i++) { 23 | sum = sum + ++i; 24 | } 25 | 26 | for (int i = 0; i < 100; i++) { 27 | sum = sum + i++; 28 | } 29 | } 30 | } 31 | /**{OpenCL{ 32 | typedef struct This_s{ 33 | int passid; 34 | }This; 35 | int get_pass_id(This *this){ 36 | return this->passid; 37 | } 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | int sum = 0; 46 | for (int i = 0; i<100; i++){ 47 | sum = sum + ++i; 48 | } 49 | for (int i = 0; i<100; i++){ 50 | sum = sum + i++; 51 | } 52 | return; 53 | } 54 | } 55 | }OpenCL}**/ 56 | 57 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/runtime/NullRefTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.runtime; 17 | 18 | import com.aparapi.Kernel; 19 | import org.junit.Ignore; 20 | import org.junit.Test; 21 | 22 | public class NullRefTest { 23 | @Ignore("Known bug, runs on CPU but not GPU.") 24 | @Test 25 | public void test() { 26 | new NullRefTest().doTest(); 27 | } 28 | 29 | private void doTest() { 30 | final Kernel kernel = new NullRefKernel(); 31 | kernel.execute(1); 32 | } 33 | 34 | private class NullRefKernel extends Kernel { 35 | private final int[] nullArray = null; 36 | 37 | @Override 38 | public void run() { 39 | if(nullArray == null) { 40 | noop(); 41 | } 42 | } 43 | 44 | private void noop() { 45 | //no op 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IndirectRecursionTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class IndirectRecursionTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void IndirectRecursionTest() { 27 | test(com.aparapi.codegen.test.IndirectRecursion.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void IndirectRecursionTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.IndirectRecursion.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/NonNullCheckTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.CodeGenException; 19 | import org.junit.Ignore; 20 | import org.junit.Test; 21 | 22 | public class NonNullCheckTest extends com.aparapi.codegen.CodeGenJUnitBase { 23 | 24 | private static final String[] expectedOpenCL = null; 25 | private static final Class expectedException = CodeGenException.class; 26 | 27 | @Test 28 | public void NonNullCheckTest() { 29 | test(com.aparapi.codegen.test.NonNullCheck.class, expectedException, expectedOpenCL); 30 | } 31 | 32 | @Test 33 | public void NonNullCheckTestWorksWithCaching() { 34 | test(com.aparapi.codegen.test.NonNullCheck.class, expectedException, expectedOpenCL); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/PostIncByteFieldTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class PostIncByteFieldTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void PostIncByteFieldTest() { 28 | test(com.aparapi.codegen.test.PostIncByteField.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void PostIncByteFieldTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.PostIncByteField.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnIntArrayNewTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.CodeGenException; 19 | import org.junit.Test; 20 | 21 | public class ReturnIntArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = CodeGenException.class; 25 | 26 | @Test 27 | public void ReturnIntArrayNewTest() { 28 | test(com.aparapi.codegen.test.ReturnIntArrayNew.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void ReturnIntArrayNewTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.ReturnIntArrayNew.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/StaticFieldStoreTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class StaticFieldStoreTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void StaticFieldStoreTest() { 28 | test(com.aparapi.codegen.test.StaticFieldStore.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void StaticFieldStoreTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.StaticFieldStore.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnLongArrayNewTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.CodeGenException; 19 | import org.junit.Test; 20 | 21 | public class ReturnLongArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = CodeGenException.class; 25 | 26 | @Test 27 | public void ReturnLongArrayNewTest() { 28 | test(com.aparapi.codegen.test.ReturnLongArrayNew.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void ReturnLongArrayNewTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.ReturnLongArrayNew.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/EntrypointRecursionTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class EntrypointRecursionTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = ClassParseException.class; 24 | 25 | @Test 26 | public void EntrypointRecursionTest() { 27 | test(com.aparapi.codegen.test.EntrypointRecursion.class, expectedException, expectedOpenCL); 28 | } 29 | 30 | @Test 31 | public void EntrypointRecursionTestWorksWithCaching() { 32 | test(com.aparapi.codegen.test.EntrypointRecursion.class, expectedException, expectedOpenCL); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IfElse.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class IfElse { 19 | public void run() { 20 | int testValue = 10; 21 | @SuppressWarnings("unused") boolean pass = false; 22 | 23 | if (testValue % 4 == 0) { 24 | pass = true; 25 | } else { 26 | pass = false; 27 | } 28 | 29 | } 30 | } 31 | /**{OpenCL{ 32 | typedef struct This_s{ 33 | 34 | int passid; 35 | }This; 36 | int get_pass_id(This *this){ 37 | return this->passid; 38 | } 39 | 40 | __kernel void run( 41 | int passid 42 | ){ 43 | This thisStruct; 44 | This* this=&thisStruct; 45 | this->passid = passid; 46 | { 47 | int testValue = 10; 48 | char pass = 0; 49 | if ( (testValue % 4) == 0){ 50 | pass = 1; 51 | } else { 52 | pass = 0; 53 | } 54 | return; 55 | } 56 | } 57 | }OpenCL}**/ 58 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnFloatArrayNewTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.CodeGenException; 19 | import org.junit.Test; 20 | 21 | public class ReturnFloatArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = CodeGenException.class; 25 | 26 | @Test 27 | public void ReturnFloatArrayNewTest() { 28 | test(com.aparapi.codegen.test.ReturnFloatArrayNew.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void ReturnFloatArrayNewTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.ReturnFloatArrayNew.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnShortArrayNewTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.CodeGenException; 19 | import org.junit.Test; 20 | 21 | public class ReturnShortArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = CodeGenException.class; 25 | 26 | @Test 27 | public void ReturnShortArrayNewTest() { 28 | test(com.aparapi.codegen.test.ReturnShortArrayNew.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void ReturnShortArrayNewTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.ReturnShortArrayNew.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Drem.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Drem { 19 | double out[] = new double[10]; 20 | double m; 21 | double n; 22 | 23 | public void run() { 24 | out[0] = m % n; 25 | } 26 | } 27 | 28 | /**{OpenCL{ 29 | #pragma OPENCL EXTENSION cl_khr_fp64 : enable 30 | 31 | typedef struct This_s{ 32 | __global double *out; 33 | double m; 34 | double n; 35 | int passid; 36 | }This; 37 | int get_pass_id(This *this){ 38 | return this->passid; 39 | } 40 | __kernel void run( 41 | __global double *out, 42 | double m, 43 | double n, 44 | int passid 45 | ){ 46 | This thisStruct; 47 | This* this=&thisStruct; 48 | this->out = out; 49 | this->m = m; 50 | this->n = n; 51 | this->passid = passid; 52 | { 53 | this->out[0] = this->m % this->n; 54 | return; 55 | } 56 | } 57 | 58 | }OpenCL}**/ 59 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnDoubleArrayNewTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.CodeGenException; 19 | import org.junit.Test; 20 | 21 | public class ReturnDoubleArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = CodeGenException.class; 25 | 26 | @Test 27 | public void ReturnDoubleArrayNewTest() { 28 | test(com.aparapi.codegen.test.ReturnDoubleArrayNew.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void ReturnDoubleArrayNewTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.ReturnDoubleArrayNew.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/SynchronizedMethodsTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.ClassParseException; 19 | import org.junit.Test; 20 | 21 | public class SynchronizedMethodsTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = ClassParseException.class; 25 | 26 | @Test 27 | public void SynchronizedMethodsTest() { 28 | test(com.aparapi.codegen.test.SynchronizedMethods.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void SynchronizedMethodsTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.SynchronizedMethods.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/Ternary.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class Ternary { 19 | 20 | float random() { 21 | return (.1f); 22 | } 23 | 24 | public void run() { 25 | @SuppressWarnings("unused") int count = (random() > .5f) ? +1 : -1; 26 | @SuppressWarnings("unused") int foo = 3; 27 | } 28 | 29 | } 30 | /**{OpenCL{ 31 | typedef struct This_s{ 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | float com_amd_aparapi_test_Ternary__random(This *this){ 38 | return(0.1f); 39 | } 40 | __kernel void run( 41 | int passid 42 | ){ 43 | This thisStruct; 44 | This* this=&thisStruct; 45 | this->passid = passid; 46 | { 47 | int count = (com_amd_aparapi_test_Ternary__random(this)>0.5f)?1:-1; 48 | int foo = 3; 49 | return; 50 | } 51 | } 52 | }OpenCL}**/ 53 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/IfBooleanOrOrOr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class IfBooleanOrOrOr { 19 | public void run() { 20 | boolean a = true, b = true, c = true, d = true; 21 | @SuppressWarnings("unused") boolean pass = false; 22 | 23 | if (a || b || c || d) { 24 | pass = true; 25 | } 26 | 27 | } 28 | } 29 | /**{OpenCL{ 30 | typedef struct This_s{ 31 | 32 | int passid; 33 | }This; 34 | int get_pass_id(This *this){ 35 | return this->passid; 36 | } 37 | 38 | __kernel void run( 39 | int passid 40 | ){ 41 | This thisStruct; 42 | This* this=&thisStruct; 43 | this->passid = passid; 44 | { 45 | char a = 1; 46 | char b = 1; 47 | char c = 1; 48 | char d = 1; 49 | char pass = 0; 50 | if (a!=0 || b!=0 || c!=0 || d!=0){ 51 | pass = 1; 52 | } 53 | return; 54 | } 55 | } 56 | }OpenCL}**/ 57 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnBooleanNewArrayTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.CodeGenException; 19 | import org.junit.Test; 20 | 21 | public class ReturnBooleanNewArrayTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | 23 | private static final String[] expectedOpenCL = null; 24 | private static final Class expectedException = CodeGenException.class; 25 | 26 | @Test 27 | public void ReturnBooleanNewArrayTest() { 28 | test(com.aparapi.codegen.test.ReturnBooleanNewArray.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | @Test 32 | public void ReturnBooleanNewArrayTestWorksWithCaching() { 33 | test(com.aparapi.codegen.test.ReturnBooleanNewArray.class, expectedException, expectedOpenCL); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/ReturnByteArrayNewTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | import com.aparapi.internal.exception.CodeGenException; 19 | import org.junit.Test; 20 | 21 | public class ReturnByteArrayNewTest extends com.aparapi.codegen.CodeGenJUnitBase { 22 | private static final String[] expectedOpenCL = null; 23 | private static final Class expectedException = CodeGenException.class; 24 | 25 | 26 | @Test 27 | public void ReturnByteArrayNewTest() { 28 | test(com.aparapi.codegen.test.ReturnByteArrayNew.class, expectedException, expectedOpenCL); 29 | } 30 | 31 | 32 | @Test 33 | public void ReturnByteArrayNewTestWorksWithCaching() { 34 | test(com.aparapi.codegen.test.ReturnByteArrayNew.class, expectedException, expectedOpenCL); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/runtime/UseBooleanTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.runtime; 17 | 18 | import com.aparapi.Kernel; 19 | import org.junit.Ignore; 20 | import org.junit.Test; 21 | 22 | public class UseBooleanTest { 23 | @Ignore("Known bug not currently fixed on GPU, works on CPU") 24 | @Test 25 | public void test() { 26 | new UseBooleanTest().executeTest(); 27 | } 28 | 29 | private void executeTest() { 30 | final Kernel kernel = new BooleanKernel(); 31 | kernel.execute(1); 32 | } 33 | 34 | private class BooleanKernel extends Kernel { 35 | private boolean isInverse = true; 36 | 37 | @Override 38 | public void run() { 39 | if (isInverse) { 40 | noop(); 41 | } 42 | } 43 | 44 | private void noop() { 45 | //no op 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/com/aparapi/codegen/test/AccessDoubleArray.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2016 - 2018 Syncleus, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.aparapi.codegen.test; 17 | 18 | public class AccessDoubleArray { 19 | double[] doubles = new double[1024]; 20 | 21 | public void run() { 22 | 23 | for (int i = 0; i < 1024; i++) { 24 | doubles[i] = 1.0; 25 | } 26 | } 27 | } 28 | /**{OpenCL{ 29 | #pragma OPENCL EXTENSION cl_khr_fp64 : enable 30 | 31 | typedef struct This_s{ 32 | __global double *doubles; 33 | int passid; 34 | }This; 35 | int get_pass_id(This *this){ 36 | return this->passid; 37 | } 38 | 39 | __kernel void run( 40 | __global double *doubles, 41 | int passid 42 | ){ 43 | This thisStruct; 44 | This* this=&thisStruct; 45 | this->doubles = doubles; 46 | this->passid = passid; 47 | { 48 | for (int i = 0; i<1024; i++){ 49 | this->doubles[i] = 1.0; 50 | } 51 | return; 52 | } 53 | } 54 | }OpenCL}**/ 55 | --------------------------------------------------------------------------------