Type stability issues when using StaticArrays

@rdeits My complete code reads the value for “nelementnodes” from an input text file. The input text file can have a different value for nelementnodes from run to run. Will this approach (value type argument) still work as intended?

See https://docs.julialang.org/en/v1/manual/performance-tips/index.html#kernel-functions-1.

As long as you create your types outside the function that do the core computation, you are fine.

1 Like

Sure! As long as your code looks something like:

function main(filename)
  nelementnodes = read_data_from_file(filename)

then you should be fine. There’s a computational cost to constructing a Val from a run-time value, but that cost is only a few hundred nanoseconds and you’re only paying it once per call of long_running_computation, so that should be completely negligible.

1 Like

Thank you @kristoffer.carlsson !

Thank you @rdeits !