Sum of squares on GPU Write a program or function that:


Takes as input a list or array of 128 numbers.
Sends that array to a GPU
Performs a calculation on the GPU to square each element of the array and then sum them
Gets the answer from the GPU, and returns or displays it


So your program will simply return the sum of the squares of its input array, but it will perform the calculation on a GPU.

The input numbers should be sent to the GPU in the form of signed or unsigned integer types or floats, of 32 or more bits in size.

You may make any assumptions you like about hardware, e.g. you may assume a CUDA or OpenCl capable card is present without checking for it.

This is code-golf. The smallest code (in bytes) will be considered the winner for each language.
APL (Dyalog Unicode) with Co-dfns, 7 bytesSBCS



Anonymous prefix lambda. I have verified with the author of Co-dfns that the code will indeed run according to the required spec.

{+.×⍨⍵}


Try it online! (equivalent code, but TIO doesn't provide GPU access)

{…} compilable dfn; ⍵ is the argument vector

 +.× dot-product of

 ⍨ itself ("selfie")

 ⍵ using the argument as data