Skip to content

Errors in filter operation code translation #30

@rcarvs

Description

@rcarvs

The following function implements the filter operation:

public void method(final int sizeIn) {
		final int[] vectorIn = new int[sizeIn];
		Random random = new Random();
		for (int x = 0; x < sizeIn; x++) {
			vectorIn[x] = random.nextInt(sizeIn);
		}
                Array<Int32> array = new Array<Int32>(vectorIn, Int32.class);
		Array<Int32> output = (Array<Int32>) array.par().filter(new Filter<Int32>() {
			@Override
			public boolean function(Int32 element) {
				boolean ret = false;
				for(int i=0;i<sizeIn;i++){
					if(element.value > vectorIn[i]){
						ret = true;
					}
				}
				return ret;
			}
		});
}

But the generated code has some errors that had to correct in order to run:

  • It did not create the vectorIn and sizeIn buffers, it passed both directly to the setArg function.
  • Inside the kernel, it did not specify the expected type of vectorIn (int *).
  • Passing vector vectorIn as int [] in the argument, I changed to jintArray and created an interpolation to cast the int *
  • It was declared a boolean type inside the kernel, I changed it to int
  • Declared a static operator inside the kernel, I removed it
  • He was by setting the PM_dataPtr->length directly in setArg, I created a buffer for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions