STDCXX-1066 [was: Re: STDCXX forks]
On 9/1/12 1:52 PM, Stefan Teleman wrote: On Sat, Sep 1, 2012 at 12:15 PM, I opened yesterday STDCXX-1066: https://issues.apache.org/jira/browse/STDCXX-1056 about the pthread_mutex_t/pthread_cond_t alignment on SPARCV8. I'll have patches done this weekend. Achtung: the patchset is very large and touches a very large number of files. It's strange that I didn't get an email about STDCXX-1066. Hi Stefan, I have read through the patches attached to the incident, then I briefly read about the SunPro pragma align and pack. Two questions: 1. AFAICT, the use of the packing pragma may interfere with a user's setting of the same value. I.e., a user sets the packing in their sources and then, directly or not, includes an STDCXX header. It seems to me that in such a situation, our setting of the packing value would interfere with the rest of the user's translation unit, since there is no way to `restore' the previous packing value. Something along the lines of: // user source file #pragma pack (X) // X != 8 #include iostream struct UserDef { // different alignment than X ? // ... }; Is my understanding correct? 2. The patches are against 4.2.1, but the change would be binary incompatible with the already released 4.2.1 branch. Do you plan to have this fix in 4.3.x? Thanks. Liviu
Re: STDCXX-1056 [was: Re: STDCXX forks]
On Sat, Sep 15, 2012 at 9:01 AM, Liviu Nicoara nikko...@hates.ms wrote: That is funny. What compiler are you using? What does the following test case return for you? It's the Intel compiler with the patched stdcxx for the wrong case and GCC 4.7.1 + GNU libstdc++ for the correct case. GCC + GNU libstdc++ are correct. The patched facet does not call the protected do_*() virtual functions from their public counterparts, as it is required to do by the Standard. Instead, it returns the data mebers directly (the data members were initialized in the constructor). That is the patch you proposed, which is indeed much better performing than using a mutex lock. Unfortunately, in doing so, overriding the virtual functions in a derived facet type becomes pointless. --Stefan -- Stefan Teleman KDE e.V. stefan.tele...@gmail.com
Re: STDCXX-1056 [was: Re: STDCXX forks]
On 9/15/12 1:51 PM, Stefan Teleman wrote: On Sat, Sep 15, 2012 at 9:01 AM, Liviu Nicoara nikko...@hates.ms wrote: That is funny. What compiler are you using? What does the following test case return for you? It's the Intel compiler with the patched stdcxx for the wrong case and GCC 4.7.1 + GNU libstdc++ for the correct case. GCC + GNU libstdc++ are correct. The patched facet does not call the protected do_*() virtual functions from their public counterparts, as it is required to do by the Standard. Instead, it returns the data mebers directly (the data members were initialized in the constructor). That is the patch you proposed, which is indeed much better performing than using a mutex lock. Unfortunately, in doing so, overriding the virtual functions in a derived facet type becomes pointless. Ahh, I see now. You are indeed right, that patch is defective. I was under the impression that we were discussing the (later) attachment stdcxx-1056-timings.tgz which contains a perfectly forwarding implementation of the facet public grouping method. The timings I attached there were the ones I thought we were discussing all along. Now, to clear the confusion I created: the timing numbers I posted in the attachment stdcxx-1056-timings.tgz to STDCXX-1066 (09/11/2012) showed that a perfectly forwarding, no caching public interface (exemplified by a changed grouping) performs better than the current implementation. It was that test case that I hoped you could time, perhaps on SPARC, in both MT and ST builds. The t.cpp program is for MT, s.cpp for ST. Please let me know if this clarifies things. I apologize for the misunderstanding. Liviu
Re: STDCXX-1066 [was: Re: STDCXX forks]
On 9/15/12 2:57 PM, Stefan Teleman wrote: On Sat, Sep 15, 2012 at 1:02 PM, Liviu Nicoara nikko...@hates.ms wrote: I have read through the patches attached to the incident, then I briefly read about the SunPro pragma align and pack. Two questions: 1. AFAICT, the use of the packing pragma may interfere with a user's setting of the same value. I.e., a user sets the packing in their sources and then, directly or not, includes an STDCXX header. It seems to me that in such a situation, our setting of the packing value would interfere with the rest of the user's translation unit, since there is no way to `restore' the previous packing value. Something along the lines of: // user source file #pragma pack (X) // X != 8 #include iostream struct UserDef { // different alignment than X ? // ... }; Is my understanding correct? Yes, you are indeed correct, Sir. :-) However, for every #pragma pack(8) there should be a corresponding subsequent #pragma pack(0). If there isn't, that's a patch bug. #pragma pack(0) restores the default alignment. So, there should be (there *must* be) no silent packing side-effects in user programs. Yes, but it restores the default packing, not an arbitrary one, potentially set by the user prior to including our headers. Say, the user sets 2, the default is 4 and we set 8. When we set it to default it goes back to 4, instead of the expected 2. Did I get this right? 2. The patches are against 4.2.1, but the change would be binary incompatible with the already released 4.2.1 branch. Do you plan to have this fix in 4.3.x? Yes, definitely for 4.2.x and 4.3.x. I sent them for 4.2.1 just because that's what I have handy. I see now. I tried to apply them to 4.2.x and some chunks failed, and I thought I was not applying them where they were intended to go. Thanks! Liviu
Re: STDCXX-1066 [was: Re: STDCXX forks]
On 9/15/12 5:19 PM, Stefan Teleman wrote: On Sat, Sep 15, 2012 at 4:57 PM, Liviu Nicoara nikko...@hates.ms wrote: Yes, but it restores the default packing, not an arbitrary one, potentially set by the user prior to including our headers. Say, the user sets 2, the default is 4 and we set 8. When we set it to default it goes back to 4, instead of the expected 2. Did I get this right? This is true, but leaving some arbirary pragma pack(N) (for N != 0) in effect for the duration of a program, and expecting it to work sounds like a very defective programming approach to me. It will certainly not work on SPARC at all. if the program needs to pack something in a certain specific way, it need to do so for that specific something only. Otherwise the side-effects of globally setting a non-default packing will destroy the program anyway. I merely wanted to point out that restoring the default packing is not the same as restoring the packing to the previous value in effect. Given this, I thought about an alternative way of forcing this alignment, e.g., via a union, aligned on an appropriate type. I see an advantage here in that most of the changes would occur where we define the 'primitive' mutex and condition wrappers, saving a few pre-processor conditionals and pragmas along the way. What do you think? Liviu