Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault executing header example #4

Closed
carojasq opened this issue Jan 27, 2016 · 4 comments
Closed

Segmentation fault executing header example #4

carojasq opened this issue Jan 27, 2016 · 4 comments

Comments

@carojasq
Copy link

Hi, I'm trying to execute this program (https://raw.githubusercontent.com/KhronosGroup/OpenCL-CLHPP/master/examples/src/headerexampleCL2.cpp) using cl2.hpp (https://www.khronos.org/registry/cl/api/2.0/cl2.hpp)

Here is my compilation and execution commands.

g++ -v -g headerexampleCL2.cpp -I ../../Cpp_common -lOpenCL -std=c++11  -o HeaderExample
./HeaderExample 

The compilation is OK. but unfortunately i always got a segmentation fault.

[1]    12260 segmentation fault (core dumped)  ./HeaderExample

From dmesg i got:

[13484.039185] HeaderExample[12697]: segfault at 0 ip           (null) sp 00007ffe46e01b48 error 14 in HeaderExample[400000+1c000]

Here is my gcc verbose log: http://pastebin.com/pNJE8mjy
Here is my platform info:http://pastebin.com/xH5LN9YY

My AMD APP SDK Version is 3.0

Please let me know if I'm doing something wrong.

@carojasq
Copy link
Author

Also I'm trying to compile enabling the macros for 1.2 compatibility.

g++ -g headerexampleCL2.cpp -I../../Cpp_common -lOpenCL -std=c++11 -DCL_HPP_TARGET_OPENCL_VERSION=120 -DCL_HPP_MINIMUM_OPENCL_VERSION=120 -DCL_HPP_CL_1_2_DEFAULT_BUILD  -o HeaderExample

But I got the same segmetation fault.

[1]    13090 segmentation fault (core dumped)  ./HeaderExample

From dmesg:

[13840.526151] HeaderExample[13090]: segfault at 0 ip           (null) sp 00007ffff433aaa8 error 14 in HeaderExample[400000+1c000]

Compilation verbose log: http://pastebin.com/82LRSS28

@carojasq carojasq changed the title Segmentation fault excuting header example Segmentation fault executing header example Jan 27, 2016
@jrprice
Copy link
Contributor

jrprice commented Feb 3, 2016

Can you give details of the device and driver version you are trying to run this with?

Can you also run this with GDB and get a backtrace to give an indication of where the crash is coming from?

I'm able to successfully run this example on AMD GPUs. This example uses OpenCL 2.0 features, so requires recent hardware and drivers to run.

@mz24cn
Copy link

mz24cn commented Feb 3, 2017

Hi @jrprice, I am also encounter segmentation fault issue on cl2.hpp. I cannot fire a bug on Khronos bugzilla so I came here:
1, I forget my bugzilla account password, I use "Forgot Password" link to send a password-reset link(hotmail.com email), tried twice, no email was received.
2, Then I try to register a new account, no sign-up link on https://www.khronos.org/bugzilla/ .

here is the minimum code to reproduce the issue:

#define CL_HPP_ENABLE_EXCEPTIONS
#define CL_HPP_TARGET_OPENCL_VERSION 200
#include <cl2.hpp>

//#define __CL_ENABLE_EXCEPTIONS
//#include <CL/cl.hpp>

#include <vector>
#include <iostream>
std::vectorcl::Device computeDevices;
cl::Device dev;

int main(int argc, char** argv)
{
std::vectorcl::Platform platforms;
try {
cl::Platform::get(&platforms);
}
catch (cl::Error&) {
return 1;
}
for (auto& platform : platforms) {
std::vectorcl::Device devices;
try {
platform.getDevices(CL_DEVICE_TYPE_GPU, &devices);
}
catch (cl::Error&) {
continue;
}
for (auto& device : devices) {
std::string name = device.getInfo<CL_DEVICE_NAME>();
computeDevices.push_back(device);
// dev = device;
}
}
std::cout << computeDevices.size() << std::endl;
return 0;
}

Note:
1, switch to cl.hpp, the issue is gone.
2, comment out "computeDevices.push_back(device);" and use the line "dev = device", segmentation fault occurs in other function when exiting; if "dev = device" only executes once, the issue disappeared.
3, I run the program on Windows 10, both NVIDIA CUDA OpenCL 1.2 driver and AMD APP SDK OpenCL 2.0 driver are installed (two discrete GPU installed).

@jrprice
Copy link
Contributor

jrprice commented Nov 6, 2018

Closing stale issue. Please reopen if the original issue is still present with the latest headers/drivers.

I believe the comment from @mz24cn relates to issue #17 which has now been addressed.

@jrprice jrprice closed this as completed Nov 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants