Hi, I'm currently implementing the platform and device chooser, and could use some help.
So far I've managed to create custom contexts for each device. I iterate through all available platforms, and setup a new context for every device in a platform. Here's how that looks: //---PLATFORMS--- platforms_type platforms = viennacl::ocl::get_platforms(); long platformCounter = 1; for(platforms_type::iterator platform_iter = platforms.begin(); platform_iter != platforms.end(); ++platform_iter){ //---DEVICES--- devices_type devices = platform_iter->devices(CL_DEVICE_TYPE_ALL); for(devices_type::iterator iter = devices.begin(); iter != devices.end(); iter++){ viennacl::ocl::setup_context( platformCounter, *iter ); } //END---DEVICES--- platformCounter++; } //END---PLATFORMS--- Then I bind each context/device to a combo box in the UI, and switch between contexts/devices like this: viennacl::ocl::switch_context(contextNumber); viennacl::ocl::current_context().switch_device(deviceNumber); There's a couple of problems: *(-1-)* It doesn't work. Switching contexts and devices by using the UI seems to work alright, but it crashes when running a benchmark. When it crashes, it gives the following feedback: -the source code of the program it was currently running; -ViennaCL: FATAL ERROR: Kernel start failed for 'vec_mul'.; -ViennaCL: Smaller work sizes could not solve the problem.; -terminate called after throwing an instance of 'viennacl::ocl::invalid_program_executable' what(): ViennaCL: FATAL ERROR: CL_INVALID_PROGRAM_EXECUTABLE.; -my screen flickers on and off while it is crashing; -and my antivirus pops up telling me it detected a malicious dll (always a random openCL-related dll) -finally, it crashes Now comes the *very* interesting part. I've got an Intel i5 2500k CPU & an AMD 7950 Radeon GPU. That means I've got 3 contexts to choose from: 1. AMD: GPU 2. AMD: CPU 3. Intel: CPU I get different behavior for each context: 1. AMD: GPU - no crash. Benchmark completes successfully with screen flicker between each sub-test in a benchmark. (The screen flicker might actually be a large console window quickly disappearing, can't say for sure). ViennCL spits out the program source code to the console. Anti virus pops a dll threat detected window. After choosing to ignore the threat, the benchmark can then be properly re-run with no issues whatsoever. The same procedure applies when running benchmark with different precision. 2. AMD: CPU - crash. This is the crash that I initially described, under *(-1-)* 3. Intel: CPU - no issues whatsoever. Benchmark runs and finishes fine using both precisions. So, what did I mess up? It's worth noting that I do the context/device switching as soon as an appropriate option has been selected with the UI combo box. It's also worth noting that I don't know in what way are platforms selected. Let me describe this in the next section. *(-2-)* Sure I iterate through all platforms and create unique contexts for each platform/device combo, but I'm not so sure the correct platform has actually been selected. That is, I'm not sure if I am *really* using a different platform, or all three contexts are bound to the same platform. Was I supposed to do something special when calling viennacl::ocl::setup_context( platformCounter, *iter );? *(-3-)* I couldn't find a way to prevent ViennaCL from creating its own context. In the manual is says: Unless specified otherwise (see Chap. 10), ViennaCL silently creates its own context and adds all available default devices with a single queue per device to it. I looked at Chap. 10, but didn't find a way to disable the auto context creation. I wish to disable it because it would make interaction with the UI a lot easier. Since the auto(0) context fails to add all devices, and I'm creating additional contexts (and one of those is bound to be the same as the one automatically created) , that complicates things when interacting with the UI. It would be much easier if I could just take care of contexts on my own. Can this be done? Apologies for the long email. Regards, Namik
------------------------------------------------------------------------------
_______________________________________________ ViennaCL-devel mailing list ViennaCL-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/viennacl-devel