Actuarial pricing, capital modelling and reserving

Pricing Squad

Issue 23 -- April 2018

Welcome to Pricing Squad

Pricing Squad is the newsletter for fellow pricing practitioners and actuaries in general insurance.

Today's issue is about your PC's computing power.

Developer announcement

Triage Classification Algorithm as described in the August 2016 Pricing Squad is now a part of the (free) ProInsurance pricing add-in for Excel.

Let me know in case you would like your own user account for downloading

Everything you always wanted to know about multi-core processors

My laptop has four CPU cores and one graphic card with GPU cores.

How many cores does your machine have?

Additional cores make computers faster. In the best case scenario, they speed things up in proportion to the number of cores.

Of course not all calculations benefit from multiple cores. A long chain of transformations where each part depends on the result of the preceding part can never be parallelized. Other problems can be parallelised in theory but our software is incapable of doing it.

So how much do additional cores speed up things in practice?

Excel lies to you (sometimes)

Before calculating a spreadsheet (with default option "enable multi-threaded calculation") Excel looks for ways to slice your calculations and run them in parallel on all available CPUs.

Spreadsheets with simple structures, no dependencies and without VBA, are the best candidates for efficient parallelisation.

You do not control how efficiently Excel parallelizes your spreadsheets. Sometimes Excel does a good job. However, typically you only gain a fraction of the theoretical improvement from additional cores.

Sometimes you gain zero but Excel will brag about using all cores just the same. I tested it by giving Excel a special job which, by design, cannot be parallelised. This example catches Excel red handed.

How to make things 350,000 times faster

Having learned about Excel, let's test more tools.

Due to my coding addiction taking over, you can now see how the following compare: Excel (with and without multi-thread support), R, C++, C++ with BLAST routines, C++ with OpenCL parallelism on a laptop, C++ with OpenCL parallelism on a GPU rig.

First things first though.

The task is to bootstrap 262,144 motor policies and apply a predictive calculation to the result. The objective - predict the distribution of outcomes after a hypothetical rate change. Of course, I use the GLM-free prediction methodology, see GIRO 2015 and PS 2017 papers.

As expected, R beats Excel and by a factor or 300. Surprisingly, R utilises a single core only! Perhaps there are advanced methods to change it but the default is one core only.

Good news for techies is that a single-core BLAST-optimised C++ code still outperforms R.

Having learned basic parallelisation with C++ OpenCL (thank you Tim Mattson and Alice Koniges for your fantastic course), I was able to benchmark the performance of 4 CPUs + 4 GPUs on a laptop. The achieved seven fold acceleration convinces me that any serious dedicated calculation software should aim at utilising all available CPU and GPU cores.

Finally, the same OpenCL code was run on a GPU rig. A rig is a personal computer fitted with multiple graphic cards. People often use rigs for mining cryptocurrency. The graphic cards are not connected to monitors - they just sit there to be farmed for computing power. You can expect a further acceleration by a factor of 30.

In summary, moving from Excel to R speeds up simulations by a factor of 300. Moving from R to a rig delivers an additional factor of 1000.


Detailed benchmarks.

Time for a single bootstrap of entire portfolio Processors utilised
Excel, disable multi-threaded calculation59 s (almost one minute)1 CPU
Excel, default settings 51 s4 CPU
R, clean code using vectors 171 ms (less than one second) 1 CPU
C++ 160 ms 1 CPU
C++, BLAST routine 41 ms 1 CPU
C++, parallel OpenCL 7 ms 4 CPU + 4 GPU
C++, OpenCL on mining rig 0.16 ms 2 CPU + 6 x 36 GPU = 218

That's it for today. Thank you for reading.

And don't forget to let me know if you need help with your pricing projects!

Copyright © 2018 Jan Iwanik, All rights reserved. You are receiving this email because you subscribed to updates from We publish data and analysis for informational and educational purposes only. You can unsubscribe from this list by emailing us.