Re: flag_complex_method = 2 in C++?
Richard Guenther wrote: Excellent. Let's see if we can have some performance numbers (from Richard ;) Uh, I know of no thing that uses complex numbers and does not manually implement them. Crazy. I understand both in C and in C++, right? Therefore, we should consider your observation in favor of simply enabling method 2 everywhere and be done with it? Paolo.
Re: flag_complex_method = 2 in C++?
On Thu, 5 Jul 2007, Paolo Carlini wrote: > Mark Mitchell wrote: > > >To be clear, my preferences, from most preferable to least are: > > > >* Method 2 is the default for all C variants, but can be overridden by > >-ffast-math, or -fcomplex-method. > > > >* Method 2 is the default for C99 and C++0x, but not for C89 or C++, but > >can be overridden by -ffast-math or -fcomplex-method. > > > >* Method 2 is the default for C99 and all variants of C++, but can be > >overridden by -ffast-math or -fcomplex-method. > > > > > Excellent. Let's see if we can have some performance numbers (from Richard ;) Uh, I know of no thing that uses complex numbers and does not manually implement them. Richard.
Re: flag_complex_method = 2 in C++?
Mark Mitchell wrote: To be clear, my preferences, from most preferable to least are: * Method 2 is the default for all C variants, but can be overridden by -ffast-math, or -fcomplex-method. * Method 2 is the default for C99 and C++0x, but not for C89 or C++, but can be overridden by -ffast-math or -fcomplex-method. * Method 2 is the default for C99 and all variants of C++, but can be overridden by -ffast-math or -fcomplex-method. Excellent. Let's see if we can have some performance numbers (from Richard ;) I hope we can directly implement your option 1. Otherwise, I can work on implementing -fcomplex-method, an excellent idea, enpowering the C++ users as I like. Paolo.
Re: flag_complex_method = 2 in C++?
Paolo Carlini wrote: > Ah, one final remark wrt C++0x: note that currently, irrespective of the > switches, there is *no way* for the user to choose method 2 in C++. I > think this is very bad in C++0x mode: essentially, as regards this > feature, it cannot track C99 as it *must*. I really hope we can enable > method 2 one way or another... Yes, that's certainly bad. To be clear, my preferences, from most preferable to least are: * Method 2 is the default for all C variants, but can be overridden by -ffast-math, or -fcomplex-method. * Method 2 is the default for C99 and C++0x, but not for C89 or C++, but can be overridden by -ffast-math or -fcomplex-method. * Method 2 is the default for C99 and all variants of C++, but can be overridden by -ffast-math or -fcomplex-method. -- Mark Mitchell CodeSourcery [EMAIL PROTECTED] (650) 331-3385 x713
Re: flag_complex_method = 2 in C++?
Hi Mark, Paolo Carlini wrote: Therefore, I'm not sure... I would certainly like to see method 2 becoming the default everywhere, on the other hand, I'm not sure if method 2 isn't too slow as default for C89 (outside fast-math, I repeat). Shall we carry out performance tests perhaps, or peak performance outside fast-math aren't really an issue here? I don't know. Performance tests would certainly be useful. I totally agree. I would ask Richard to help here... In case of doubt, I would still switch to method 2 as default together with C++0x, in that case the reference C language is C99 and things are very neat... The problem is that this isn't how users think about it. If a user does: gcc test.c g++ test.c and gets different performance between the two, I think we're going to have a "C++ is slow" bug report. In a certain sense, the user may be right, in that C99/C++ mandate a slower approach than is used by GNU C89. But, because GNU C89 is the default, we still have a problem. I see your point. As you clearly see in your second sentence, I see things slightly differently, I would not be much on the side of users comparing the performance of C++0x to C89... But anyway this is just an academic issue, for now... Since C99 has defined semantics for this, and C++ is following, it seems reasonable to me to change C89 to always use these semantics. Then, some GNU C89 programs may go a bit slower, but we don't have weird differences between the languages. And, users can use -ffast-math to get the performance back -- in all languages, uniformly. ... assuming we can enable method everywhere, that would be great. Ah, one final remark wrt C++0x: note that currently, irrespective of the switches, there is *no way* for the user to choose method 2 in C++. I think this is very bad in C++0x mode: essentially, as regards this feature, it cannot track C99 as it *must*. I really hope we can enable method 2 one way or another... Paolo.
Re: flag_complex_method = 2 in C++?
Paolo Carlini wrote: > Therefore, I'm not sure... I would certainly like to see method 2 > becoming the default everywhere, on the other hand, I'm not sure if > method 2 isn't too slow as default for C89 (outside fast-math, I > repeat). Shall we carry out performance tests perhaps, or peak > performance outside fast-math aren't really an issue here? I don't know. Performance tests would certainly be useful. > In case of doubt, I would still switch to method 2 as default together > with C++0x, in that case the reference C language is C99 and things are > very neat... The problem is that this isn't how users think about it. If a user does: gcc test.c g++ test.c and gets different performance between the two, I think we're going to have a "C++ is slow" bug report. In a certain sense, the user may be right, in that C99/C++ mandate a slower approach than is used by GNU C89. But, because GNU C89 is the default, we still have a problem. Since C99 has defined semantics for this, and C++ is following, it seems reasonable to me to change C89 to always use these semantics. Then, some GNU C89 programs may go a bit slower, but we don't have weird differences between the languages. And, users can use -ffast-math to get the performance back -- in all languages, uniformly. -- Mark Mitchell CodeSourcery [EMAIL PROTECTED] (650) 331-3385 x713
Re: flag_complex_method = 2 in C++?
Hi Mark, I'd prefer not to introduce a situation in which compiling the same code with "gcc" and with "g++" behaves differently and which performs worse in one case than the other. Users expect the C subset of C++ to perform like C. If we want the C99 rules, let's just turn them on everywhere, and then let users who want "quick and dirty" complex arithmetic to use the flag that turns that on. And, turn that on by default for -ffast-math? Let's start again from the end of your answer: fast-math includes cx_limited_range, which in turn leads to the very fast method *0* being used. Therefore, in any case, we cannot have performance issues in fast-math mode. I briefly remind that currently we have *3* different methods, and method 1 is the default but for C99, where the default is 2: /* 0 means straightforward implementation of complex divide acceptable. 1 means wide ranges of inputs must work for complex divide. 2 means C99-like requirements for complex multiply and divide. */ Therefore, I'm not sure... I would certainly like to see method 2 becoming the default everywhere, on the other hand, I'm not sure if method 2 isn't too slow as default for C89 (outside fast-math, I repeat). Shall we carry out performance tests perhaps, or peak performance outside fast-math aren't really an issue here? I don't know. In case of doubt, I would still switch to method 2 as default together with C++0x, in that case the reference C language is C99 and things are very neat... Paolo.
Re: flag_complex_method = 2 in C++?
Richard Guenther wrote: >> I'm having a look to libstdc++/30482, which basically is C++ issue: Jakub >> basically raises the issue of whether we want to use by default the >> C99-conforming division in C++ too. Personally, I would be in favor of >> enabling it unconditionally, modulo maybe a performance check (Richard...). >> Otherwise, we should at least enable it for C++0x, which refers to C99 as C >> language, of course. >> >> What do people think? > > Well, I agree to enable this by default. I'd prefer not to introduce a situation in which compiling the same code with "gcc" and with "g++" behaves differently and which performs worse in one case than the other. Users expect the C subset of C++ to perform like C. If we want the C99 rules, let's just turn them on everywhere, and then let users who want "quick and dirty" complex arithmetic to use the flag that turns that on. And, turn that on by default for -ffast-math? -- Mark Mitchell CodeSourcery [EMAIL PROTECTED] (650) 331-3385 x713
Re: flag_complex_method = 2 in C++?
On Thu, 5 Jul 2007, Paolo Carlini wrote: > Hi, > > I'm having a look to libstdc++/30482, which basically is C++ issue: Jakub > basically raises the issue of whether we want to use by default the > C99-conforming division in C++ too. Personally, I would be in favor of > enabling it unconditionally, modulo maybe a performance check (Richard...). > Otherwise, we should at least enable it for C++0x, which refers to C99 as C > language, of course. > > What do people think? Well, I agree to enable this by default. Richard.