[Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au --- src/mesa/x86/x86_function_opt.h | 42 + 1 file changed, 42 insertions(+) create mode 100644 src/mesa/x86/x86_function_opt.h Using a macro like this means we can easily enable runtime support in clang once it also supports it. Also its less of an impact for those compiling with the optimisations enabled. Finally I'm assuming its also better for lto. diff --git a/src/mesa/x86/x86_function_opt.h b/src/mesa/x86/x86_function_opt.h new file mode 100644 index 000..c1ffb19 --- /dev/null +++ b/src/mesa/x86/x86_function_opt.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) Timothy Arceri + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Author: + *Timothy Arceri t_arc...@yahoo.com.au + * + */ + +/* + * Helper macros to enable per function optimisations + * + */ + +#ifdef __SSSE3__ + #define SSSE3_FUNC_OPT_START + #define SSSE3_FUNC_OPT_END +#else + #if (__GNUC__ 4 || (__GNUC__ == 4 __GNUC_MINOR__ 3)) + #define SSSE3_FUNC_OPT_START _Pragma(GCC push_options) \ + _Pragma(GCC target(\ssse3\)) + #define SSSE3_FUNC_OPT_END _Pragma(GCC pop_options) + #endif +#endif -- 1.9.3 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
I rather to not use compiler specific hacks in mesa. If it was a personal pet project it would make sense. Best regards, Siavash Eliasi. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
On Sat, Nov 8, 2014 at 4:59 AM, Siavash Eliasi siavashser...@gmail.com wrote: I rather to not use compiler specific hacks in mesa. If it was a personal pet project it would make sense. We use compiler-specific things all the time. That's not going to change. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
On 08/11/14 11:12, Timothy Arceri wrote: Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au As long as it fixes odd combinations such as this the following I'm all in favour of using such an approach. It will save us quite a few lovely details - split the file, configure checks etc... https://bugs.freedesktop.org/show_bug.cgi?id=71547 Just a small nit below :) Thanks Emil --- src/mesa/x86/x86_function_opt.h | 42 + 1 file changed, 42 insertions(+) create mode 100644 src/mesa/x86/x86_function_opt.h Using a macro like this means we can easily enable runtime support in clang once it also supports it. Also its less of an impact for those compiling with the optimisations enabled. Finally I'm assuming its also better for lto. diff --git a/src/mesa/x86/x86_function_opt.h b/src/mesa/x86/x86_function_opt.h new file mode 100644 index 000..c1ffb19 --- /dev/null +++ b/src/mesa/x86/x86_function_opt.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) Timothy Arceri + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the Software), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Author: + *Timothy Arceri t_arc...@yahoo.com.au + * + */ + +/* + * Helper macros to enable per function optimisations + * + */ + +#ifdef __SSSE3__ + #define SSSE3_FUNC_OPT_START + #define SSSE3_FUNC_OPT_END +#else + #if (__GNUC__ 4 || (__GNUC__ == 4 __GNUC_MINOR__ 3)) Normally I've preferred to have #if defined(__GNUC__) (__GNUC__ 4 + #define SSSE3_FUNC_OPT_START _Pragma(GCC push_options) \ + _Pragma(GCC target(\ssse3\)) + #define SSSE3_FUNC_OPT_END _Pragma(GCC pop_options) + #endif +#endif ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
On Sat, 2014-11-08 at 18:13 +, Emil Velikov wrote: On 08/11/14 11:12, Timothy Arceri wrote: Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au As long as it fixes odd combinations such as this the following I'm all in favour of using such an approach. It will save us quite a few lovely details - split the file, configure checks etc... https://bugs.freedesktop.org/show_bug.cgi?id=71547 Hmmm, what a pain. I'm not sure what GCC target will do in this case, will need to check. It will be a shame if we can't enable these optimisations just because people wish to build in this way. Just a small nit below :) Thanks Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
On Sat, 2014-11-08 at 16:29 +0330, Siavash Eliasi wrote: I rather to not use compiler specific hacks in mesa. If it was a personal pet project it would make sense. Best regards, Siavash Eliasi. Having to work around compiler differences is a real world problem. As has been pointed out before msvc handles function specific optimisations using intrinsics automatically. GCC and Clang don't so to avoid the multiple issues cause by having to move things to a different file we need to work around it. Thankfully macros allow the impact to be minimised. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
I know that's a time saver for developer (gcc function multi versioning), however I still do prefer the approach (my own ^^ ) which works on all setups regardless of hardware and compiler (well, any sane compiler ICC, GCC, Clang,...). Best regards, Siavash Eliasi. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
On Sun, 2014-11-09 at 08:59 +1100, Timothy Arceri wrote: On Sat, 2014-11-08 at 18:13 +, Emil Velikov wrote: On 08/11/14 11:12, Timothy Arceri wrote: Signed-off-by: Timothy Arceri t_arc...@yahoo.com.au As long as it fixes odd combinations such as this the following I'm all in favour of using such an approach. It will save us quite a few lovely details - split the file, configure checks etc... https://bugs.freedesktop.org/show_bug.cgi?id=71547 Hmmm, what a pain. I'm not sure what GCC target will do in this case, will need to check. ok, so for the intel driver it doesn't build with this type of setup anyway as intel_mipmap_tree.c still uses #if defined(USE_SSE41) you end up with undefined symbol: _mesa_streaming_load_memcpy at runtime. Once I removed the calls to _mesa_streaming_load_memcpy is seems GCC target overrides the no-ssse3 flag so it seems it will be fine as long as a runtime check is in place. It will be a shame if we can't enable these optimisations just because people wish to build in this way. Just a small nit below :) Thanks Emil ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 2/3] mesa: helper macros to enable per function optimisations
On Sun, 2014-11-09 at 07:48 +0330, Siavash Eliasi wrote: I know that's a time saver for developer (gcc function multi versioning), however I still do prefer the approach (my own ^^ ) which works on all setups regardless of hardware and compiler (well, any sane compiler ICC, GCC, Clang,...). Best regards, Siavash Eliasi. This isn't about saving development time, and the whole point of it is so things work *well* on all compilers. In an ideal world we wouldn't have to do compiler specific things, but in the real world if you want Mesa to be fast this is the right direction to go in. To look at it another way putting different versions of functions in another file is a hack too. At least this way we can have link time optimisations, inlining improvements, etc. I think you may not be following what this patch is doing. This patch is not an alternative to your patch, it works along side it. Your patch is about runtime selection this patch is about compile time. ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev