~ubuntu-branches/ubuntu/wily/pyopencl/wily

« back to all changes in this revision

Viewing changes to src/wrapper/tools.hpp

  • Committer: Package Import Robot
  • Author(s): Tomasz Rybak
  • Date: 2012-06-21 21:18:03 UTC
  • mfrom: (2.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20120621211803-424gma7uil7lje4u
* New upstream release.
* Depend on free ocl-icd-libopencl1 instead of non-free libraries.
* Add NEWS entry describing OpenCL library dependencies.
* Change my email.
* Move python-pyopengl from Recommends to Suggests because package
  can be used for computations without any graphical environment.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _ASDFDAFVVAFF_PYCUDA_HEADER_SEEN_TOOLS_HPP
 
2
#define _ASDFDAFVVAFF_PYCUDA_HEADER_SEEN_TOOLS_HPP
 
3
 
 
4
 
 
5
 
 
6
 
 
7
#include <boost/python.hpp>
 
8
#include <numeric>
 
9
#include "numpy_init.hpp"
 
10
 
 
11
 
 
12
 
 
13
 
 
14
namespace pyopencl
 
15
{
 
16
  inline
 
17
  npy_intp size_from_dims(int ndim, const npy_intp *dims)
 
18
  {
 
19
    if (ndim != 0)
 
20
      return std::accumulate(dims, dims+ndim, 1, std::multiplies<npy_intp>());
 
21
    else
 
22
      return 1;
 
23
  }
 
24
 
 
25
 
 
26
 
 
27
 
 
28
  inline void run_python_gc()
 
29
  {
 
30
    namespace py = boost::python;
 
31
 
 
32
    py::object gc_mod(
 
33
        py::handle<>(
 
34
          PyImport_ImportModule("gc")));
 
35
    gc_mod.attr("collect")();
 
36
  }
 
37
}
 
38
 
 
39
 
 
40
 
 
41
 
 
42
 
 
43
#endif