Hi all
I've been using a complex udf written in c# using excel-dna. I have made this function thread-safe (I hope) and marked it as such. It does indeed run a lot faster than before. I've also tried it out on a number of computers and virtual machines with differing numbers of cores (everything from 4 to 16) with quite interesting results.
Excel has a way of specifying how many threads you want to allow it to use for thread-safe udfs. This is under options/advanced/formulas.
I've found that for my function, I get best results in general if the number of calculation threads is 1 less than the number of processors. So if I have 4 cores, setting number of threads to 3 gave me the best performance. If I have 8 cores, the best results were obtained by setting calculation threads to 7.
There were some strange results for 16 cores on a dual processor xeon virtual machine:
Using 64 bit excel, I got the best results when setting calculation threads to 15.
Using 32 bit excel, I got the best results when setting calculation threads to 8 (or thereabouts).
I wonder if anyone can explain this?
Also, I wonder if anyone knows how to programatically determine the number of cores available, and how to programatically set the number of calculation threads to be used by udfs in excel.
All the best
Simon