I am writing a user defined surface DLL, and want to know if I can speed up the DLL by storing specific precomputed values in FIXED_DATA4 or FIXED_DATA5 datasurf values.
In my DLL I have several variables (a1, a2, a3 etc) which are affected by the curvature, conic constant, and one of my surface parameters (which will not vary during optimisation). The sag of the surface is a function in x and y, with different powers of x and y multiplied by these variables. eg. a1*x + a2*x*y + ...
I may be misunderstanding how the DLL works, but I currently expect that each time it is called it will compute my variables (a1,a2 etc) and then calculate the sag, meaning that it is inefficiently repeating the same calculations many times, where I only need to compute the sag from the variables which are fixed during any raytracing and optimisation.
Can I add code on initialisation to store the curvature, conic constant, and param[1] to the data surf values as well as the corresponding variables a1 etc, and then each time the sag or raytrace is called just check whether the values have changed from the stored ones, and recompute my variables if so. My expectiation is that comparing 3 variables is faster than calculating multiple variables with different math fuctions. I am mainly unsure if this is going to cause a problem due to parallel calls of the DLL or other details of how the DLL is implemented which I am not aware of as I don't have much experience with them. I also appreciate that the improvement may be minimal, as the compiler should do some optimisation of the calculation, but I don't know how much.
Thanks for any help.