Extra Benefit of Modern C++ to Edge computing

how compile-time programming help accelerate the run-time?

Huang Kevin
2 min readJul 4, 2021

One of key features in modern C++ is the introduction of compile-time programming — compiler is able to make evaluation(for constexpr variable) and deduction (for type or function) during compilation. So, how edge computing could benefit from this feature? In this post, I came up with a simple example to elucidate the benefit of compile-time programming to edge computing?

How compile-time programming help edge computing ?

Since code could be cross-compiled in more powerful computer at computing center, the compiled executable can later be deployed into edge device w/ less computational power.

Compilation and run session could be done in different computers.

Therefore, I came up w/ a simple demo code to test the run-time w/ or w/o the help of compile-time pre-calculation.

Test result is shown as follow:

W/ calculation in compile-time, time(msec): 3.302e-05
W/o calculation in compile-time, time(msec): 2.183

As shown above, run time w/ the help of compile-time pre-calculation is faster than that w/o pre-calculation by 5 order of magnitude!!

In conclusion, if we need a heavy calculation which is conceivable before we put the whole system into deployment, compile-time programming can finish this calculation in advance, and speed up the run-time dramatically.

--

--

Huang Kevin

Algorithm engineer at semiconductor company with background in physics