Skip to content
Snippets Groups Projects
Commit f3328211 authored by Alex Rothberg's avatar Alex Rothberg
Browse files

specify the build options using the -o flag. Updated docs and example notebook

parent cd72c375
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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",
......
......@@ -33,7 +33,9 @@ class PyOpenCLMagics(Magics):
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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment