[PyOpenCL] Segementation fault
Nick Gaens
nickgaens at gmail.com
Sun Oct 18 05:19:22 PDT 2009
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Dijkstra_cl.zip
Type: application/x-zip-compressed
Size: 1804 bytes
Desc: not available
URL: <http://lists.tiker.net/pipermail/pyopencl/attachments/20091018/c4b03dfd/attachment.bin>
More information about the PyOpenCL
mailing list