[Haskell-beginners] Performance problem with Haskell/OpenGL/GLFW

Hollister Herhold hollister at fafoh.com
Sun Mar 10 15:14:41 CET 2013


OK, I get the same results as you. I ran a dtruss on the two different apps to look at the system calls being made and I can see where the C code opens the OpenGL hardware driver and the haskell code does not, but I'm not sure why. There are a lot of preferences files flying around. Still digging.

I do know that both apps are using the same glfw library.


On Mar 10, 2013, at 8:23 AM, Hollister Herhold wrote:

> 
> I'm building glfw now on 10.7.5 and I'll try your test code. 
> 
> I've been learning haskell (still very much a beginner) but I know OpenGL, so I'm very interested in how this turns out.
> 
> -Hollister
> 
> 
> On Mar 10, 2013, at 4:38 AM, Jesper Särnesjö wrote:
> 
>> On Sun, Mar 10, 2013 at 4:46 PM, Jesper Särnesjö <sarnesjo at gmail.com> wrote:
>>> I've figured out what the problem is: the Haskell program is using a
>>> software implementation of OpenGL, so rendering *does* in fact happen
>>> on the CPU.
>>> 
>>> It would appear that there is in fact some relevant difference between
>>> the Haskell and C versions of my program, or possibly some way
>>> in which the bindings from the GLFW-b package are different from the C
>>> library.
>> 
>> To remove any possibility of the problem being in GLFW-b or OpenGLRaw,
>> I created two new programs, one in Haskell [1] and one in C [2], that
>> don't import or include anything related to OpenGL, and that simply
>> create a context, check if it is hardware accelerated, and then exit.
>> That is all. And still, the Haskell program receives a software
>> renderer, while the C program receives a hardware one:
>> 
>>   $ ghc -O2 Test2.hs -lglfw -framework OpenGL -fforce-recomp && ./Test2
>>   [1 of 1] Compiling Main             ( Test2.hs, Test2.o )
>>   Linking Test2 ...
>>   software
>>   (2,7,7)
>>   (3,2,0)
>>   $ gcc -O2 test2.c -lglfw -framework OpenGL && ./a.out
>>   hardware
>>   2.7.7
>>   3.2.0
>> 
>> I haven't had the chance to run these programs on any OS other than
>> Mac OS X 10.8.2, so I don't know if this problem is Mac-specific.
>> Still, it's really weird that the system would differentiate between
>> Haskell and C programs in this way.
>> 
>> If anyone has any ideas about what's going on here, I'd very much like
>> to hear them.
>> 
>> -- 
>> Jesper Särnesjö
>> http://jesper.sarnesjo.org/
>> 
>> [1] https://gist.github.com/sarnesjo/5116084#file-test2-hs
>> [2] https://gist.github.com/sarnesjo/5116084#file-test2-c
>> 
>> _______________________________________________
>> Beginners mailing list
>> Beginners at haskell.org
>> http://www.haskell.org/mailman/listinfo/beginners
> 
> 
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners




More information about the Beginners mailing list