- Big problem with templates - 4 Updates
- static guard locks - 4 Updates
- tdm gcc 5.1 slower than 4.7 - 2 Updates
- threading problems - 1 Update
jacobnavia <jacob@jacob.remcomp.fr>: Aug 27 11:31PM +0200 I am trying to maintain a huge C++database application with templates all around. In 2010, tokens and identifiers were resolved at template expansion time. Somehow this behaviour changed between 2010 and today and now I am getting hundreds of undefined references in those templates. How can I revert to the good old times? The compiler that compiled this is gcc-4.4.3, and still does. The new compiler however will not do that even if I specify -std=c++98 Thanks in advance. jacob |
Paavo Helde <myfirstname@osa.pri.ee>: Aug 27 04:46PM -0500 jacobnavia <jacob@jacob.remcomp.fr> wrote in news:mrnvfg$b9g$2@dont- email.me: > getting hundreds of undefined references in those templates. > How can I revert to the good old times? > The compiler that compiled this is gcc-4.4.3, and still does. I suspect this was a defect in older versions of gcc. Fix your code to conform to the standard. If your templates are never instantiated, you can just delete them, for example. Cheers Paavo |
jacobnavia <jacob@jacob.remcomp.fr>: Aug 28 12:04AM +0200 Le 27/08/2015 23:46, Paavo Helde a écrit : > Fix your code to > conform to the standard. Of course! How stupid from me. I just have to fix 344,356 lines of templated code... Thanks anyway. jacob |
Ian Collins <ian-news@hotmail.com>: Aug 28 10:15AM +1200 jacobnavia wrote: >> conform to the standard. > Of course! > How stupid from me. I just have to fix 344,356 lines of templated code... The answer was as generic as the question. If you want a better answer, provide some examples. -- Ian Collins |
Prroffessorr Fir Kenobi <profesor.fir@gmail.com>: Aug 27 12:24PM -0700 W dniu czwartek, 27 sierpnia 2015 21:09:03 UTC+2 użytkownik Nobody napisał: > > 1) how serious this problem is? > How frequently are those functions called? And if they're called from > multiple threads, how much contention do you expect for the locks? hell i dont know i got hundreds of them though mostly they are simple statics foo() { static int x = 1; } like that are you sure this situation above do not generate such locks? i used this swich and my app binary bloat went down 100KB from 350KB down to 250 KB * what dam could generate whole 100kB of bloat? im not using multithreaded only one core though sse optimised * this was a half of a problem described in another thread near here, there is yet second when changing compiler from gcc 4.6/4.7 to 4.8/4.9/5.1 frame time drops down from 20 ms to 23.5 ms - this switch elimineted bloat but has no effect on code slowdown |
Paavo Helde <myfirstname@osa.pri.ee>: Aug 27 03:36PM -0500 Prroffessorr Fir Kenobi <profesor.fir@gmail.com> wrote in >> so how to turn it off ? i dont know the appriopriate naming to >> immediatel > y find it I see Nobody has already provided the answer. FWIW, my google search terms were: gcc avoid static mutex locks > besides that..isnt it silly (worse than silly) for gcc to do that - it > slows and bloats code that do not need that... It's required by the C++11 standard. Most performance-critical C++ apps are multithreaded nowadays in order to make use of multiple CPU cores, so this makes a lot of sense. (And if your code is not performance-critical you will not notice the difference). Cheers Paavo |
Prroffessorr Fir Kenobi <profesor.fir@gmail.com>: Aug 27 02:08PM -0700 W dniu czwartek, 27 sierpnia 2015 22:37:03 UTC+2 użytkownik Paavo Helde napisał: > are multithreaded nowadays in order to make use of multiple CPU cores, so > this makes a lot of sense. (And if your code is not performance-critical > you will not notice the difference). this above is probably untrue.. for example when i was writing my own multicore apps i was using arrays of statics indexed by thread ordinal number (like 1,2,3,4)... that should probably work with no locks - im not sure as i was not working/thinking longer on this and here with this guard lock.. do this lock is acquired on every entry to the function or only once...? (i dont quite understand how it works) beslides slowdown, bloat is scarry |
Paavo Helde <myfirstname@osa.pri.ee>: Aug 27 04:33PM -0500 Prroffessorr Fir Kenobi <profesor.fir@gmail.com> wrote in > multicore apps i was using arrays of statics indexed by thread ordinal > number (like 1,2,3,4)... that should probably work with no locks - im > not sure as i was not working/thinking longer on this This sounds like thread-specific statics, there is a special keyword for them in C++11 (thread_local). > and here with this guard lock.. do this lock is acquired on every > entry to the function or only once...? (i dont quite understand how it > works) What is protected is the initialization of the static. I guess depending on the implementation this may or may not mean a mutex lock on each entry. > beslides slowdown, bloat is scarry So care to provide numbers for the slowdown? How many percents your program rans faster when compiled with -fno-threadsafe-statics? About bloat: you must be using lots of statics. Time to start getting rid of them, statics are evil even if multithreading is not involved. Cheers Paavo |
Vir Campestris <vir.campestris@invalid.invalid>: Aug 27 09:21PM +0100 On 26/08/2015 20:40, Prroffessorr Fir Kenobi wrote: > it is scary.. what can i do with it? (the rest of settings etc is the same i only rename the compiler folder from one to anither > (If co maybe i should download the whole variety of 10 versions and check which one is the best :C, > as i said this is scary to me) What optimisation settings are you using? Andy |
Prroffessorr Fir Kenobi <profesor.fir@gmail.com>: Aug 27 02:02PM -0700 W dniu czwartek, 27 sierpnia 2015 22:21:23 UTC+2 użytkownik Vir Campestris napisał: > > as i said this is scary to me) > What optimisation settings are you using? > Andy c:\mingw\bin\g++ -std=c++98 -O2 -c -w test7.c -fno-rtti -fno-exceptions -fno-threadsafe-statics -march=core2 -mtune=generic -mfpmath=both -msse2 (-std=c++98 was used to check if it would be maybe speed up but not a difference) |
seeplus <gizmomaker@bigpond.com>: Aug 27 04:19AM -0700 On Thursday, August 27, 2015 at 6:38:20 AM UTC+10, Christopher Pisz wrote: > I program on Windows, but I am none too happy with the Window's API and > have managed to stay away from Windows Thread functions, since boost > 1.32 or so /aside/ Are you using Boost threads with Windows GUI? I have been using MFC/API threads successfully to start/suspend/restart/stop, and get the thread reporting back to the OS about what it is doing, all good. However in the future I would like to expand this, and have more control and knowledge of how it works. I have not tried Boost, but have used the offshoot just::threads, produced by the Boost threads maintainer so it should work similarly? Does not work well for me. Cannot control the thread much, (but it does report back OK via Win messaging). AND it stops the Win 8-10 OS from multitasking until the thread finishes, presumably because it is not fitting in with Win slicing and messaging. Cannot find good Win code examples for this (or Boost really), even with ~50 bookmarks : ( so it is on hold. Grasping at threads is .... mind numbing. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment