Hi,
When I create my MSVS 2012 project via CMake and turn on compilation for OpenMP, compilation fails because a few implementations in QuantLib (lattice.hpp, ninepointlinearop.cpp, triplebandlinearop.cpp), use for loops with indices being of type Size, which is defined as size_t, which is unsigned. In the supplied project files the flag to compile for OpenMP is however not set, so this problem will not show up. Surely this can easily be fixed by changing the types to int? Shall I change and commit a patch? Or am I doing something wrong here? Kind regards, Joost B.W. Geerdink
------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Hi,
strange that openmp should prohibit unsigned indexes in loops. It has no such limitation in either gcc or clang. What error are you getting? Luigi On Wed, Feb 26, 2014 at 4:08 PM, Joost Geerdink <[hidden email]> wrote: > Hi, > > When I create my MSVS 2012 project via CMake and turn on compilation for > OpenMP, compilation fails because a few implementations in QuantLib > (lattice.hpp, ninepointlinearop.cpp, triplebandlinearop.cpp), use for loops > with indices being of type Size, which is defined as size_t, which is > unsigned. In the supplied project files the flag to compile for OpenMP is > however not set, so this problem will not show up. > > Surely this can easily be fixed by changing the types to int? Shall I change > and commit a patch? Or am I doing something wrong here? > > Kind regards, > > Joost B.W. Geerdink > > ------------------------------------------------------------------------------ > Flow-based real-time traffic analytics software. Cisco certified tool. > Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer > Customize your own dashboards, set traffic alerts and generate reports. > Network behavioral analysis & security monitoring. All-in-one tool. > http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk > _______________________________________________ > QuantLib-users mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-users > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
The MSVS compiler version 17 for x64 returns this error: methods\finitedifferences\operators\ninepointlinearop.cpp(148): error C3016: 'i' : index variable in OpenMP 'for' statement must have signed integral type The culprit: #pragma omp parallel for for (Size i=0; i < retVal.size(); ++i) { The new version of openmp does allow unsigned indices, but even the newest MSVS doesn't support that yet.
Kind regards, Joost On Wed, Feb 26, 2014 at 4:16 PM, Luigi Ballabio <[hidden email]> wrote: Hi, ------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by ikku100
I have only little experience with OpenMP, and that was 10+ years ago, but I cannot believe that you can’t use unsigned loop indices with it. If
that is indeed the case, I’d tend to regard it as a bug in OpenMP, and ask THEM to fix it, unless there are reasons for enforcing that rule that I can’t imagine. I suspect the problem is more subtle, perhaps signed-unsigned comparisons (which however, as far as I know, should only trigger a warning) or different
types being used in some place where they can’t be converted automatically. That is, not a problem with OpenMP per se, but a problem that happens to be present only in code paths that are compiled only if OpenMP is enabled. Which error messages do you get exactly, and can you reduce the problem to a smaller test case? Gerardo Gerardo Ballabio Risk Management Banca Profilo S.p.A.
Via Cerva 28 - 20122 Milano
Tel.
+39 02 58408.463 Da: Joost Geerdink [mailto:[hidden email]]
Hi, When I create my MSVS 2012 project via CMake and turn on compilation for OpenMP, compilation fails because a few implementations in QuantLib (lattice.hpp, ninepointlinearop.cpp, triplebandlinearop.cpp), use for loops with indices being
of type Size, which is defined as size_t, which is unsigned. In the supplied project files the flag to compile for OpenMP is however not set, so this problem will not show up. Kind regards, Joost B.W. Geerdink
------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by ikku100
So it’s an OpenMP restriction indeed. I’m amazed. There must be a reason why they did that, but I cannot imagine what it may be. Gerardo Gerardo Ballabio Risk Management Banca Profilo S.p.A.
Via Cerva 28 - 20122 Milano
Tel. +39 02 58408.463 Da: Joost Geerdink [mailto:[hidden email]]
The MSVS compiler version 17 for x64 returns this error: methods\finitedifferences\operators\ninepointlinearop.cpp(148): error C3016: 'i' : index variable in OpenMP 'for' statement must have signed integral type The culprit: #pragma omp parallel for for (Size i=0; i < retVal.size(); ++i) { The new version of openmp does allow unsigned indices, but even the newest MSVS doesn't support that yet. Kind regards, Joost On Wed, Feb 26, 2014 at 4:16 PM, Luigi Ballabio <[hidden email]> wrote: Hi,
> ------------------------------------------------------------------------------
------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by ikku100
I see. There should be no problem in patching the code to turn those
into ints, except that I'm all set to release 1.4 tomorrow, I have a few busy weeks ahead and I'd rather be done with the release and not go through all the checks again after patching. So I'd release with the Size indices and leave it to you to patch it untli a bug-fix release sometime in the near future. Would that be a problem? Later, Luigi On Wed, Feb 26, 2014 at 4:23 PM, Joost Geerdink <[hidden email]> wrote: > The MSVS compiler version 17 for x64 returns this error: > > methods\finitedifferences\operators\ninepointlinearop.cpp(148): error C3016: > 'i' : index variable in OpenMP 'for' statement must have signed integral > type > > The culprit: > #pragma omp parallel for > for (Size i=0; i < retVal.size(); ++i) { > > The new version of openmp does allow unsigned indices, but even the newest > MSVS doesn't support that yet. > > Kind regards, > > Joost > > > On Wed, Feb 26, 2014 at 4:16 PM, Luigi Ballabio <[hidden email]> > wrote: >> >> Hi, >> strange that openmp should prohibit unsigned indexes in loops. It >> has no such limitation in either gcc or clang. What error are you >> getting? >> >> Luigi >> >> >> On Wed, Feb 26, 2014 at 4:08 PM, Joost Geerdink <[hidden email]> wrote: >> > Hi, >> > >> > When I create my MSVS 2012 project via CMake and turn on compilation for >> > OpenMP, compilation fails because a few implementations in QuantLib >> > (lattice.hpp, ninepointlinearop.cpp, triplebandlinearop.cpp), use for >> > loops >> > with indices being of type Size, which is defined as size_t, which is >> > unsigned. In the supplied project files the flag to compile for OpenMP >> > is >> > however not set, so this problem will not show up. >> > >> > Surely this can easily be fixed by changing the types to int? Shall I >> > change >> > and commit a patch? Or am I doing something wrong here? >> > >> > Kind regards, >> > >> > Joost B.W. Geerdink >> > >> > >> > ------------------------------------------------------------------------------ >> > Flow-based real-time traffic analytics software. Cisco certified tool. >> > Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer >> > Customize your own dashboards, set traffic alerts and generate reports. >> > Network behavioral analysis & security monitoring. All-in-one tool. >> > >> > http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk >> > _______________________________________________ >> > QuantLib-users mailing list >> > [hidden email] >> > https://lists.sourceforge.net/lists/listinfo/quantlib-users >> > >> >> >> >> -- >> <https://implementingquantlib.blogspot.com> >> <https://twitter.com/lballabio> > > -- <https://implementingquantlib.blogspot.com> <https://twitter.com/lballabio> ------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
On 2/26/2014 16:56, Luigi Ballabio wrote:
> I see. There should be no problem in patching the code to turn those > into ints, except that I'm all set to release 1.4 tomorrow, I have a > few busy weeks ahead and I'd rather be done with the release and not > go through all the checks again after patching. So I'd release with > the Size indices and leave it to you to patch it untli a bug-fix > release sometime in the near future. Would that be a problem? Hi! As someone who has faced this issue before, perhaps I can add a quick comment. This is a limitation of the current level of OpenMP support in Visual Studio. The latest supported version is OpenMP 2.0, see: https://msdn.microsoft.com/en-us/library/fw509c3b.aspx This limitation has been relaxed in OpenMP 3.0 (not supported by MSVC); see Appendix F, "Changes from Version 2.5 to Version 3.0": "Random access iterators, and variables of unsigned integer type, may now be used as loop iterators in loops associated with a loop construct (see Section 2.5.1 on page 38)." // Source: http://www.openmp.org/mp-documents/spec30.pdf As of today there has been no updates on the OpenMP 3.0 support: https://connect.microsoft.com/VisualStudio/feedback/details/545147/openmp-3-0-support I would NOT recommend using `int` to address this issue -- this may bring a whole new set of bugs (e.g., loss of data, possible regression in performance due to size-conversions). Consider using either `std::ptrdiff_t` or Boost's `make_signed<std::size_t>::type`: - http://en.cppreference.com/w/cpp/types/ptrdiff_t - http://www.boost.org/doc/libs/release/libs/type_traits/doc/html/boost_typetraits/reference/make_signed.html If potential performance regression is not an issue and the goal is to avoid data loss at all costs, then even `boost::intmax_t` may be worth considering: http://www.boost.org/libs/integer Best, Matt ------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
@Gerardo: That explains, thanks. @Matt: exactly :) About the int vs all sorts of other variable types: loss of data will only occur when the numbers become extremely large, maybe something to look at but not probable. The limit of the loop is the size of some array and if that array would be as large as the max positive value of an int the memory size of the vector would be extremely large (larger than available memory?).
About the regression in speed... ok, maybe. But not sure if this piece of the code is that sensitive. But to be honest I do not see a reason why NOT to use std::ptrdiff_t On Wed, Feb 26, 2014 at 10:57 PM, Matt <[hidden email]> wrote:
------------------------------------------------------------------------------ Flow-based real-time traffic analytics software. Cisco certified tool. Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer Customize your own dashboards, set traffic alerts and generate reports. Network behavioral analysis & security monitoring. All-in-one tool. http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk _______________________________________________ QuantLib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
Free forum by Nabble | Edit this page |