I have got very similar problem to this one stated here : Intel CPU OpenCL in Mono killed by SIGXCPU (Ubuntu)

Essentially, I have a very simple C# application using OpenCL (through OpenCL.Net wrapper, but it shouldn't make a difference as it is merely wrapping native functions and nothing more). In the code I just build kernel and then allocate a big array of floats.

To be more specific my platform: It is Ubuntu 12.04, OpenCL 1.1 (with CUDA) and mono 3.0.3.

Problem: When running my code through mono i get CPU LIMIT EXCEEDED error

Few things:

  • If I set a breakpoint (in monodevelop) somewhere between building the kernel and allocation it works..
  • Changing array size to small one also makes it work

Strace doesn't show anything useful. I tried also passing a callback to ClBuildProgram (to note: if I comment out line with ClBuildProgram it works).

Any ideas?

有帮助吗?

解决方案

That's what worked for me in the end.

There is a major problem with mono - it uses SIGXCPU for GC handling (which is strange btw). Unfortunately OpenCL uses it as well so it conflicts.

Workaround is to modify mono code.

Go to source directory and grep -r SIGXCPU . In my mono (3.0.3) there were 2 imporant files

./libgc/pthread_stop_world.c:# define SIG_THR_RESTART SIGXCPU

./mono/metadata/sgen-os-posix.c:const static int restart_signal_num = SIGXCPU;

Replace SIGXCPU with SIGWINCH and recompile. One note is that I am not sure if it didn't break something, but for now looks OK and OpenCL problem is gone. If it breaks something (like gui) replace SIGWINCH with different signal that you have (signals.h for signals defs)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top