Also posted at: https://stackoverflow.com/questions/53576439/pyopencl-comparison-of-integers-of-different-signs-problem

I'm on a MacBook Pro with Intel graphics. I have extremely limited experience with C code.

There's not a lot of code here, but the actual problem is probably in the C/OpenCl code generated by the python module.

The compiler generates many repetitions of:

<program source>:819:47: warning: comparison of integers of different signs: 'unsigned long' and 'const psc_index_type' (aka 'const int')
                if (psc_K * psc_LID_0 + psc_k < psc_offset_end)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~

The code used is as follows:

import pyopencl as cl
import pyopencl.array
import pyopencl.algorithm
import numpy as np

platform = cl.get_platforms()
my_devices = platform[0].get_devices(device_type=cl.device_type.GPU)
ctx = cl.Context(devices=my_devices)
queue = cl.CommandQueue(ctx)

aryary = np.array([[10, 11, 12, 13, 14, 15, 16, 17], [1, 2, 3, 4, 0, 0, 0, 0], [108, 0, 0, 0, 0, 0, 0, 0]], np.int32)
cl_aryary = cl.array.to_device(queue, aryary)
lenary = np.array([8, 4, 1], np.int32)
cl_lenary = cl.array.to_device(queue, lenary)

result = cl.algorithm.copy_if(
  cl_aryary,
  "sum_array(&ary[i], len[i]) == 108",
  extra_args=[('len', cl_lenary)],
  preamble='''
    int sum_array(__global int *a, int num_elements);

    int sum_array(__global int *a, int num_elements)
    {
       int i, sum=0;
       for (i=0; i<num_elements; i++)
       {
          sum = sum + a[i];
       }
       return(sum);
    }
  ''',
  queue=queue
)

print(result)


There's not a lot of code here, but the actual problem is probably in the C/OpenCl code generated by the python module.

The compiler generates many repetitions of:

<program source>:819:47: warning: comparison of integers of different signs: 'unsigned long' and 'const psc_index_type' (aka 'const int')
                if (psc_K * psc_LID_0 + psc_k < psc_offset_end)
                    ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~
The code used is as follows:

import pyopencl as cl
import pyopencl.array
import pyopencl.algorithm
import numpy as np

platform = cl.get_platforms()
my_devices = platform[0].get_devices(device_type=cl.device_type.GPU)
ctx = cl.Context(devices=my_devices)
queue = cl.CommandQueue(ctx)

aryary = np.array([[10, 11, 12, 13, 14, 15, 16, 17], [1, 2, 3, 4, 0, 0, 0, 0], [108, 0, 0, 0, 0, 0, 0, 0]], np.int32)
cl_aryary = cl.array.to_device(queue, aryary)
lenary = np.array([8, 4, 1], np.int32)
cl_lenary = cl.array.to_device(queue, lenary)

result = cl.algorithm.copy_if(
  cl_aryary,
  "sum_array(&ary[i], len[i]) == 108",
  extra_args=[('len', cl_lenary)],
  preamble='''
    int sum_array(__global int *a, int num_elements);

    int sum_array(__global int *a, int num_elements)
    {
       int i, sum=0;
       for (i=0; i<num_elements; i++)
       {
          sum = sum + a[i];
       }
       return(sum);
    }
  ''',
  queue=queue
)

print(result)


I've tried tweaking lots of things here but can't track down what is blocking this code from compiling, running and actually producing a result.

_______________________________________________
PyOpenCL mailing list
PyOpenCL@tiker.net
https://lists.tiker.net/listinfo/pyopencl

Reply via email to