Doesn't build with nvidia CL implementation:
:40: error: subscripted value is neither array nor pointer
if (result_distances[x][y] < min_dist && resistancemap[x]
[y] != args[NO_DATA_VALUE]) {
^
~
:52: error: subscripted value is neither array nor pointer
if (x >= 0 && y >= 0 && x < n_rows &&
y < n_cols &&
resistancemap[x][y] != args[NO_DATA_VALUE]) {
^
~
:54: error: subscripted value is neither array nor pointer
alt = result_distances[loc.y][loc.x] +
resistancemap[x][y]/2 + resistancemap[loc.y][loc.x]/2;
^
~
:56: error: subscripted value is neither array nor pointer
alt = result_distances[loc.y][loc.x] + SQRT_TWO *
resistancemap[x][y] + SQRT_TWO * resistancemap[loc.y][loc.x];
^
~
:66: error: subscripted value is neither array nor pointer
resistancemap[loc.y][loc.x] = args[NO_DATA_VALUE];
^ ~~~~~
Andreas
On Sonntag 18 Oktober 2009, Nick Gaens wrote:
Hello all,
we're trying to get a variation on the Dijkstra algorithm to run in
pyOpenCL, but we're getting a weird segmentation fault on the line where
the ALERT comment is located. A print statement before and after this
line indicates this position.
Following is the code that initializes the arrays and stuff and loads
the C code of Dijkstra (located in Dijkstra.cl):
Dijkstra_cl.py:
...
ctx = cl.Context([device])
queue = cl.CommandQueue(ctx,
properties=cl.command_queue_properties.PROFILING_ENABLE)
# Contains the resistance map
table = numpy.zeros(shape=(100,100))
# Contains the remaining arguments for the Dijkstra call
# [no_data_value, start_x, start_y, end_x, end_y]
Dijkstra_args = numpy.ndarray((5,), buffer=numpy.array([-9999,
0, 1, 2, 3]), dtype = numpy.int32)
# The map 'table' will be read from and written to by the
Dijkstra-method
mf = cl.mem_flags
table_buff = cl.Buffer(ctx, mf.READ_WRITE | mf.USE_HOST_PTR,
hostbuf = table)
Dijkstra_cl_src = ""
try:
Dijkstra_cl_file = open("Dijkstra.cl")
Dijkstra_cl_src = Dijkstra_cl_file.read()
Dijkstra_cl_file.close()
except IOError as error:
print error
prg = cl.Program(ctx, Dijkstra_cl_src).build()
exec_evt = prg.Dijkstra(queue, table.shape, table_buff,
Dijkstra_args) # ALERT: segfaults here
exec_evt.wait()
elapsed = 1e-9 * (exec_evt.profile.end - exec_evt.profile.start)
print "Execution time of test: %g s" % elapsed
c = numpy.empty_like(table)
cl.enqueue_read_buffer(queue, table, c).wait()
Dijkstra.cl:
...
__kernel void Dijkstra ( __global float* resistancemap, __global
const int* args ) {
// Dijkstra
// Remark: the parameter "resistancemap" is read from
and written to, but since we've previously set the READ_WRITE flag, this
should not be a problem or is it?
}
Can someone point us out what exactly is going wrong? I've attached both
source files in case important information is missing.
A second question is: is it possible to somehow debug the C-code that
you build and run via print-statements or so?
Regarding the second question: what about #include statements in C? The
compiler just says e.g.: "file <math.h> not found" when trying to
regularly including it.
Thx in advance,
Nick