Skip to content

Commit

Permalink
specify the build options using the -o flag. Updated docs and example…
Browse files Browse the repository at this point in the history
… notebook
  • Loading branch information
cancan101 committed Jul 17, 2014
1 parent cd72c37 commit f332821
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/misc.rst
Expand Up @@ -37,6 +37,8 @@ and then use the ``%%cl_kernel`` 'cell-magic' command. See `this notebook
<http://nbviewer.ipython.org/urls/raw.githubusercontent.com/pyopencl/pyopencl/master/examples/ipython-demo.ipynb>`_
(which ships with PyOpenCL) for a demonstration.

You can pass build options to be used for building the program executable by using the ``-o`` flag on the first line of the cell (next to the ``%%cl_kernel`` directive). For example: `%%cl_kernel -o "-cl-fast-relaxed-math"``.
.. versionadded:: 2014.1
Guidelines
Expand Down
2 changes: 1 addition & 1 deletion examples/ipython-demo.ipynb
Expand Up @@ -106,7 +106,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
"%%cl_kernel\n",
"%%cl_kernel -o \"-cl-fast-relaxed-math\"\n",
"\n",
"__kernel void sum_vector(__global const float *a,\n",
"__global const float *b, __global float *c)\n",
Expand Down
4 changes: 3 additions & 1 deletion pyopencl/ipython_ext.py
Expand Up @@ -33,7 +33,9 @@ def cl_kernel(self, line, cell):
raise RuntimeError("unable to locate cl context, which must be "
"present in namespace as 'cl_ctx' or 'ctx'")

prg = cl.Program(ctx, _try_to_utf8(cell)).build(options=_try_to_utf8(line).strip())
opts, args = self.parse_options(line,'o:')
build_options = opts.get('o', '')
prg = cl.Program(ctx, _try_to_utf8(cell)).build(options=_try_to_utf8(build_options).strip())

for knl in prg.all_kernels():
self.shell.user_ns[knl.function_name] = knl
Expand Down

0 comments on commit f332821

Please sign in to comment.