GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Aug 25, 2016 2:41 am

All times are UTC

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: gtk thread or openmp
PostPosted: Sat Sep 22, 2012 6:44 am 
GTK+ Guru

Joined: Sun Jul 08, 2012 3:14 pm
Posts: 111
Location: Coventry, UK
Dear friends,
Back to my treeview question It seems to take a long time before it can finish creating the tree. So, I am thinking of making that part parallel.
Now, here is a question of choice. Should I stick to gdk_threads or should I use openmp?
My situation (only to be considered if gdk_thread and openmp is in equal footing): i know openmp(with fortran, implementing it in C may not be a huge problem)

 Post subject: Re: gtk thread or openmp
PostPosted: Sat Sep 22, 2012 8:08 am 
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 1046
Location: UK

You can use any of these if you want multi threading, but there are many problems when using threads that you must be aware of. The main one for GTK+ is that it can only be called from ONE thread at a time. This means you should do all of your GTK+/GDK in the main thread only with other worker threads passing data onto the main thread. Or you could use the possibly soon to be deprecated gdk_threads_enter()/gdk_threads_leave() to protect all calls to GTK+/GDK that are not done in the main thread.

Using gdk_threads_enter()/gdk_threads_leave() is not advisable as openmp would not know anything about it and cause problems, it is not portable, and it may soon be deprecated.

As another note making your application multi-threaded may not speed up your code and could possibly slow it down.

Have you profiled your code to find out where all the time is spent and why? This way you can work out why your code is slow and possibly come up with a better solution rather than hit it with a hammer solution.


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group