Type stability issues when using StaticArrays


#22

@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?


#23

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.


#24

Sure! As long as your code looks something like:

function main(filename)
  nelementnodes = read_data_from_file(filename)
  long_running_computation(Val(nelementnodes))
end

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.


#25

Thank you @kristoffer.carlsson !


#26

Thank you @rdeits !