- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there a standard way to test if an FPE had occurred in one of the TBB threads? I'd like to start using the parallel foreach to do some numerical operations, and I need to know when the processing is done, if an FPE had occurred during any of the calculations. In my serial code on Windows and Linux I am clearing the floating point flags before doing a vector operation, and then checking the result flag afterward.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There isno built-in way to do the test.The best solution is totreat the problem as reduction, where the reduction operation combines FPE flags from different portions of the calculation.
I've attached an example that does this. I tested it on Linux. It calculates A/B. Initially both A and B are one. Successive runs perturb the values. It should print:
I've attached an example that does this. I tested it on Linux. It calculates A/B. Initially both A and B are one. Successive runs perturb the values. It should print:
[cpp]No exceptions Setting B[N/2]=3 Exceptions occurred: FE_INEXACT Setting B[N/2]=0 Exceptions occurred: FE_DIVBYZERO Setting A[N/2]=0 Exceptions occurred: FE_INVALID Setting A[N/2]=1E37 Setting B[N/2]=1E-37 Exceptions occurred: FE_INEXACT FE_OVERFLOW Setting A[N/2]=1E-37 Setting B[N/2]=1E37 Exceptions occurred: FE_INEXACT FE_UNDERFLOW[/cpp]The key part to study is the functor Body, and how it manipulates Body::fp_excepts. Also look at where the parallel_reduce is invoked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the example. I think your approach makes a lot of sense and the code was clear.
Juan
Quoting - Arch Robison (Intel)
Juan
Quoting - Arch Robison (Intel)
There isno built-in way to do the test.The best solution is totreat the problem as reduction, where the reduction operation combines FPE flags from different portions of the calculation.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page