Recently discovered the wonderful VexCL library, I decided to try using it to speed up the work of the Python extension, which performs a number of mathematical calculations. In the extension, element-wise operations are performed on arrays, which I would like to replace with template expressions with VexCL vectors. However, for some reason, when the Python module is loaded, it completely hangs. The problem is most likely not in the module code, since it still hangs before the program reaches the first lines of its code. Context stored in a global variable structure.
// file.h #include "vexcl/devlist.hpp" struct Config { bool use_vexcl; vex::Context vexcl_ctx; Config(); }; extern Config config; void init_config(); //file.cpp #include <iostream> #include "config.h" using namespace std; Config::Config() : use_vexcl(true) , vexcl_ctx(vex::Filter::Any && vex::Filter::DoublePrecision) { cout << "Config constructor with VexCL" << endl; if (!vexcl_ctx) throw std::runtime_error("No VexCL devices available"); } Config config; void init_config() { cout << "Init config..." << endl; config = Config(); } The init_config() function is executed in the extension immediately after all #include . However, the program execution flow does not reach it either ("Init config ..." is not displayed). If you comment out all the code using VexCL, execution does not stop.
Is this related to VexCL, or with some logical errors in my code? How can I fix this (and is it possible at all)?
PS It is worth noting that the Python extension module is essentially a dll library. Used OpenCL backend to VexCL.
It was tested on Windows 8.1, Python 3.4 was used and the compiler from Microsoft Visual C ++ 10.0. The project is organized in such a way that the above code is part of a library, statically linked with the extension.
Config()constructor, which is called when you create the globalconfigobject, the second time inside theinit_config()function. Those. Hangup most likely occurs during the first initialization. Does the same VexCL code work on your machine outside of the Python module? - ddemidovinit_config()the same thing happens. Wrappers for c ++ classes I describe in Cython. Outside the Pyoton module, everything is fine (I tried on two machines). - Doctor Lemmanconfigininit_config(), then everything works as it should. I can not understand why this is ... - Doctor Lemman September