Off screen rendering when laptop shuts screen down?
Asked Answered
P

3

11

I have a lengthy number-crunching process which takes advantage of quite abit of OpenGL off-screen rendering. It all works well but when I leave it to work on its own while I go make a sandwich I would usually find that it crashed while I was away.
I was able to determine that the crash occurs very close to the moment The laptop I'm using decides to turn off the screen to conserve energy. The crash itself is well inside the NVIDIA dlls so there is no hope to know what's going on.

The obvious solution is to turn off the power management feature that turns the screen and video card off but I'm looking for something more user friendly. Is there a way to do this programatically?
I know there's a SETI@home implementation which takes advantage of GPU processing. How does it keep the video card from going to sleep?

Parthia answered 26/12, 2008 at 20:25 Comment(0)
E
9

I'm not sure what OS you're on, but windows sends a message that it is about to enter a new power state. You can listen for that and then either start processing on the CPU or deny the request to enter a lower-power state.

Efflux answered 26/12, 2008 at 20:35 Comment(0)
Z
8

For the benefit of Linux users encountering a similar issue, I thought I'd add that, you can obtain similar notifications and inhibit power state changes using the DBUS API. An example script in Python, taken from the link, to inhibit power state change:

#!/usr/bin/python
import dbus
import time
bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
devobj = bus.get_object('org.freedesktop.PowerManagement', 
                        '/org/freedesktop/PowerManagement')
dev = dbus.Interface (devobj, "org.freedesktop.PowerManagement.Inhibit")
cookie = dev.Inhibit('Nautilus', 'Copying files from /media/SANVOL')
time.sleep(10)
dev.UnInhibit(cookie)
Zygophyllaceous answered 26/12, 2008 at 21:20 Comment(0)
T
0

According to MSDN, there is an API that allows an application to tell Windows that it is still working and that Windows should not go to sleep or turn off the display.

The function is called SetThreadExecutionState (MSDN). It works for me, using the flags ES_SYSTEM_REQUIRED and ES_CONTINUOUS.

Note, however, that using this function does not stop the screen saver from running, which might interfere with your OpenGL app if the screen saver also uses OpenGL (oder Direct3D).

Trent answered 2/2, 2010 at 13:7 Comment(1)
Turning off the display is not the same as activating the screensaver. Those are two independent settings. -1Tisdale

© 2022 - 2024 — McMap. All rights reserved.