QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

ikku100
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
Reply | Threaded
Open this post in threaded view
|

Re: QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

Luigi Ballabio
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
Reply | Threaded
Open this post in threaded view
|

Re: QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

ikku100
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>


------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

R: QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

Ballabio Gerardo-4
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

www.bancaprofilo.it

 

Descrizione: http://www.bancaprofilo.it/~/media/Images/B/Banca-Profilo/logo/logo.jpg

 

 

Da: Joost Geerdink [mailto:[hidden email]]
Inviato: mercoledì 26 febbraio 2014 16.08
A: [hidden email]
Oggetto: [Quantlib-users] QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

 

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




Banca Profilo S.p.A. Via Cerva, 28 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057 Capitale Sociale Euro 136.794.106,00 i.v. Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email] Iscritta all’Albo delle Banche e dei Gruppi bancari Aderente al Fondo Interbancario di Tutela dei depositi Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A. DISCLAIMER: The information transmitted may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

R: QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

Ballabio Gerardo-4
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

www.bancaprofilo.it

 

Descrizione: http://www.bancaprofilo.it/~/media/Images/B/Banca-Profilo/logo/logo.jpg

 

 

Da: Joost Geerdink [mailto:[hidden email]]
Inviato: mercoledì 26 febbraio 2014 16.24
A: Luigi Ballabio
Cc: QuantLib users
Oggetto: Re: [Quantlib-users] QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

 

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>

 




Banca Profilo S.p.A. Via Cerva, 28 - 20122 Milano - Tel. 02 58408.1, Fax 02 5831 6057 Capitale Sociale Euro 136.794.106,00 i.v. Iscrizione al Registro Imprese di Milano, C.F. e P.IVA 09108700155 - [hidden email] Iscritta all’Albo delle Banche e dei Gruppi bancari Aderente al Fondo Interbancario di Tutela dei depositi Aderente al Conciliatore Bancario Finanziario e all’Arbitro Bancario Finanziario Appartenente al Gruppo bancario Banca Profilo e soggetta all’attività di direzione e coordinamento di Arepo BP S.p.A. DISCLAIMER: The information transmitted may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer.

------------------------------------------------------------------------------
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
Reply | Threaded
Open this post in threaded view
|

Re: QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

Luigi Ballabio
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
Reply | Threaded
Open this post in threaded view
|

Re: QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

Matt
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
Reply | Threaded
Open this post in threaded view
|

Re: QL latests with OpenMP 2.0 and MSVS 2012 (and CMake)

ikku100
@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:
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


------------------------------------------------------------------------------
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