GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Sep 01, 2014 6:36 pm

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 
Offline
GTK+ Guru

Joined: Sun Jul 08, 2012 3:14 pm
Posts: 107
Location: Coventry, UK
Dear friends,
Back to my treeview question http://www.gtkforums.com/viewtopic.php?f=3&t=178128. 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)


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

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

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.

_________________
E.


Top
 Profile  
 
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], Google Adsense [Bot] and 4 guests


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