OpenCL clGetPlatformIDs causes access violation only when ran from Visual Studio - c++

This is a strange one for me. I'm currently pulling a project from an old repo of mine that I've recently migrated to VS2015. The solution still builds and the executable works, but when running in visual studio I get an access violation in the call to clGetPlatformIDs() trying to read from 0x000008E0.
I honestly have no clue what it could be as it's very strange: the builds work themselves but not from VS. Debugging through I can confirm all the parameters are as expected but the function still fails. I updated the OpenCL implementation to Intel's OpenCL SDK version 6.3 but that didn't fix the problem and I don't have the symbols to dig any deeper into the function.
Code is simple, but I've posted it below anyway.
//Get Platforms
cl_platform_id * platforms = new cl_platform_id[6];
cl_uint numPlatforms = 0;
cl_uint numPlatformsToCheck = 6;
error = clGetPlatformIDs(numPlatformsToCheck, platforms, &numPlatforms);
printCLError( "Getting Platforms", error );

So I just had the same issue: I got an access violation exception on any OpenCL function. Fresh install of the Intel OpenCL SDK, all drivers up-to-date. Only happens when ran inside of Visual Studio.
I found a solution.
There would be an access violation in igdrcl64.dll, causing the exception. This library is part of the IntelHD Graphics drivers and there apparently used to be a bug in the DLL. But I don't have this driver installed (using NVIDIA graphics card), also the bug is supposedly fixed by now. It turns out the IntelHD driver's uninstaller does not remove all it's DLL's, so the buggy DLL's were left on my machine and not updated.
Fix: Remove the DLL's manually (only if you don't use IntelHD graphics!)
On 64-bit version of Windows OS:
C:\Windows\System32\igdbcl64.dll
C:\Windows\System32\igdfcl64.dll
C:\Windows\System32\igdrcl64.dll
C:\Windows\SysWOW64\igdbcl32.dll
C:\Windows\SysWOW64\igdfcl32.dll
C:\Windows\SysWOW64\igdrcl32.dll
On 32-bit version of Windows OS:
C:\Windows\System32\igdbcl32.dll
C:\Windows\System32\igdfcl32.dll
C:\Windows\System32\igdrcl32.dll
I hope this will help someone.

I think you are using clGetPlatformIDs wrong. First, call clGetPlatformIDs(numPlatformsToCheck, NULL, &numPlatforms);
Then:
cl_platform_id * platforms = new cl_platform_id[numPlatforms];
Finally: error = clGetPlatformIDs(numPlatformsToCheck, platforms, NULL);
printCLError( "Getting Platforms", error );
In general OpenCL query commands are:
Query to get number of items in a list
Allocate the memory for the list
Populate list
The issue is probably that it is either trying to find 6 platforms where there are not 6 platforms or something is funky in the library when all parameters are entered.

Related

Why does Window geometry change when migrating from VS2010 to VS2017?

I have a large Win API C++ Application that i recently moved from Visual Studio 2010 to 2017. Application compiles, links and runs now, but i find that the window borders are about 2 pixels larger than before.
This is a problem as we implemented docking windows long time ago with 100% own code. Although all sizes are retrieved from the OS using GetSystemMetrics etc. this turned out to need some more specific alignment. It took a lot of development time when developing (for Windows 2000) and retargeting later for Windows 7. Furthermore we have some small windows and the thicker frames just waste space.
So i installed the Windows SDK 7.1 and was able after some tweaks to install that. But i am not able to choose 7.1 in the project settings. Typing in that in the project settings results in
error MSB8036: The Windows SDK version 7.1 was not found.
Although I find a directory named:
C:\Program Files\Microsoft SDKs\Windows\v7.1
Also when trying to re-target the Project, the SDK 7.1 is not listed.
I did a lot of googling and found this and that but no substantial answer. msdn is horrible.
Questions (obsolet, see below):
Is it possible to use VC 2017 with Windows 7 SDK? How?
Is there possibly a different way to keep the geometry used with VC2010?
EDIT:
I don't think that this is a duplicate of Dialog border different after porting code from Visual Studio 6 to Visual Studio 2013 although the link is quite helpful. It turned out, that different values are returned for GetSystemMetrics(SM_CYFRAME). So far I do not see a substantial explanation for that. Please see my own answer and comments.
So let me update the question:
Why does the value returned from GetSystemMetrics(SM_CYFRAME) change when upgrading from VC2010 to VC2017?
What is the root cause?
Is it possible to use VC 2017 with Windows 7 SDK? How?
Yes, but I doubt this is the solution to your main problem.
Is there possibly a different way to keep the geometry used with VC2010?
Yes, just change the minimum subsystem version to pre-Vista value, like 5.01 (for Windows XP 32-bit). For some reason, 5.1 will yield the same result too; the resulting EXE would be the same.
When Win32 Subsystem Version is 6.0 or above, there is a behavior change regarding the window border size. Though I am not aware of where Microsoft has documented about this.
If you still have Windows 7, the difference is also obvious when you are using Windows Basic theme, as shown in this screenshot:
Screenshot added by RED SOFT ADAIR:
It turned out that the problem was as described here:
https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/eaae1445-264d-487f-aba1-52dfc8abdfe4/getsystemmetrics-difference-in-return-value-for-the-same-input?forum=windowssdk
The value returned for GetSystemMetrics(SM_CXFRAME) changed with VS 2013.
In VS2010 (Window 8.1)
GetSystemMetrics(SM_CXFRAME); // 8 pixels
In VS2013 (Window 8.1, same PC)
GetSystemMetrics(SM_CYFRAME); // 4 pixels
In VC2013 and later the same result will be returned using
GetSystemMetrics(SM_CXFRAME) + GetSystemMetrics(SM_CXPADDEDBORDER);
My windows still had the same frame size. I miss interpreted the root cause.
Still i do not understand how this can happen. By my understanding GetSystemMetrics is a function of the Windows OS. How can this function behave different when changing the compiler? I guess this IS part of the Windows SDK?
By the way, i found, that i can select "Windows 7.1" as the Platform Toolset, but not for the SDK (as i was thinking).
All this is confusing. Can anybody point out the differences and the junctions between SDK and Toolset?
EDIT:
I made a little sample program to prove this:
#include <windows.h>
#include <stdio.h>
int main(int argc, char *argv)
{
printf("GetSystemMetrics(SM_CXFRAME) returns: %d\n", GetSystemMetrics(SM_CXFRAME));
return 0;
}
Compiling with VC2010 results in "8".
Compiling with VC2017 results in "4".
Even if i choose "dont upgrade" for the SDK when migrating to VC2017.
If you dont believe it - try yourself.
If you have any more insights to that - you're welcome. I give you a 500 points bounty!

C++ - unable to start correctly (0xc000001d) - openCV

I'm trying to run an OpenCV 2.3.1 application through Microsoft Visual C++ 2008. I have generated the release exe file correctly, and it works fine on my windows 8 - 64 bits. In addition I would like to run it on Win XP, so I have tested it on a Win XP SP3 and it ran ok. However, when I try to run this exe on Win XP SP2, which is the target O.S. for my app, I get the following message:
unable to start correctly (0xc000001d). Click Accept to finish the
application
Any idea please?
Finally I have solved the issue: 0xC000001D: Illegal instruction, which was related to the SSE instruction used in the code. Some new SSE instruction are not implemented at some different CPU; In this case, the problem was related with my CPU: "via nehemiah". I tested the software again on a XP SP2 with CPU Intel and it worked perfectly. Finally I have to say that there is a great post which was helpful in order to fix the issue:
Unhandled exception at 0x52f9e470 in project1.exe : 0xC000001D : Illegal instruction

How do I compile 64 bit SDL code using Code Blocks(Without admin rights)

I am running windows 7 64bit and
I am trying to set up SDL on my school laptop which I do not have admin rights for.
The project compiles fine but when I try to run it I get an error saying " the application was unable to start correctly (0xc000007b)." I Have experienced this error before when trying to run the same 32bit program on my 64bit computer at home. By compiling using 64 bit methods the issue was resovled however I do not have access to a 64bit compiler on my school laptop because I cant find any compilers that don't require admin rights to set up. So If you know of a 64bit compiler download that requires no ADMIN rights to install or if you have an alternate method I would appreciate it.
My stats
Code_blocks 12.11
SDL 1.2.15
SDL_image1.2.10
The compiler that came with codeblocks From Here http://www.codeblocks.org/downloads/26#windows
codeblocks-12.11mingw-setup_user.exe
try tdm-gcc: http://tdm-gcc.tdragon.net/
as for 0xc000007b problem:
it may occur when you don't have a working 32bit directx on yout 64bit system, you should update your directx, this may help solve the problem.
directx update: http://www.microsoft.com/download/details.aspx?id=35

VC 2010 Executable Not Running on Other Computers - No Errors

I'm running into a strange thing while making a game in VC++. I'm using the Cocos2d-x platform and VC++ 2010 in Windows 7 and it works perfectly fine on my machine. However, I have another computer that is Windows XP. I am currently using /MT so there is no problem with the runtime library, but the program doesn't run in Windows XP and it doesn't even produce an error. I have tried with 2010 C++ redist on the other computer, and it doesn't work with or without. There is nothing in the console and no error log. Nothing appears odd in DependencyWalker, only missing internet explorer frame stuff. What can cause a program on windows XP to execute and close immediately without leaving an error?
Anyone has any ideas? I am using the game framework's dynamic linked libraries, so could that be a problem? Also, even though I linked statically, my executable is only about 140 KB. Is something messing up?
Thanks for any help.
EDIT: There's also an interesting problem with CRT I ran into before. When I ran the program with permission level "asInvoker" on windows 7, I got a "CRT Not Initialized" error. Once I set it to "highestAllowed", it started working but I was wondering if it had anything to do with CRT?
Okay, I've found the problem. It turns out that my other computer has an integrated Intel Graphics card that doesn't support the graphics renderer (OpenGL ES 2.0) that the framework uses. That's why it ends up crashing without outputting any errors.
Thanks to anyone who helped.

Deployed C++ AMP application stops responding

Im trying to deploy a C++ AMP application to another Windows 7 machine.
I have tried to include the vcamp110.dll in the same folder, and also compiled with /MT do get rid of dependency on msvcp110.dll and msvcr110.dll.
Also tried both x64 and win32 release of the application.
On the computers i have tried it on whitout VS11 installed, the program stops responding.
I tried to do a simple test with the hello world application and i have the same problems there.
The files can be downloaded from here http://www.2shared.com/file/IofZlrJs/amptest.html (source, binary and the dll).
Any suggestions to how this can be fixed?
Deployments like the one you tried are definitely supported – full details here:
http://blogs.msdn.com/b/nativeconcurrency/archive/2012/03/12/deploying-apps-built-with-c-amp.aspx
There are a few things you can do to diagnose the issue you are facing yourself:
The bitness of vcamp110.dll has to match the bitness of your app, so 32bit for one means 32bit for the other.
Ensure that there are no other instances of vcamp110.dll in some central location (e.g. system32)
Attach a debugger and see what DLLs are loaded and what exception gets thrown.
Most important of all, for all your apps, surround your parallel_for_each call with try…catch to see what runtime_exception you are getting. More on C++ AMP exceptions can be found here: http://blogs.msdn.com/b/nativeconcurrency/archive/2012/02/01/c-amp-runtime-exceptions.aspx
For the specific repro you shared, we tried that under the debugger on a clean Windows 7 machine and indeed a rutime_exception is being thrown: “The binary for the parallel_for_each is incompatible with this version of runtime.”, which indicates a mismatched runtime version (either mixing bitness or mixing Developer Preview with Beta or something like that).