For any technical computing, you should always use optimized libraries when available. Existing libraries used by hundreds of other people will be better tested and better optimized than everything that you do yourself, and the time when you do not spend time writing (and debugging and optimization) that work independently, you can better spend real work a high-level problem that you want to solve, instead of rediscovering things that other people have already implemented. This is simply the main specialization of labor; focus on the computational problem you want to solve, and let the people who spend their days professionally writing GPGPU routines do it for you.
Only when you are sure that existing libraries do not do what you need, maybe they solve a too general problem or make certain assumptions that are not fulfilled in your case - if you abandon your own.
I agree with others that in this particular case, the operation is quite simple, and this is possible for DIY; but if you are going to do anything else with these matrices as soon as you add them, you are better off using optimized BLAS routines for any platform you are on.
source share