From martinwguy at gmail.com Mon Apr 15 03:43:28 2024 From: martinwguy at gmail.com (Martin Guy) Date: Mon, 15 Apr 2024 05:43:28 +0200 Subject: Muliply vector by vector? Message-ID: <1f13b998-df89-4e3a-a7c4-358b8e9fef3d@gmail.com> If often have to multiply one array of floats each element with the corresponding one in another array of floats and store the result in a third array, mostly to apply window functions to audio fragments. Can liboil help? The closest things I see in the Liboil Reference Manual that seems close multiply an array by a constant and put the result in another array. Am I missing something? Might this be a good candidate for inclusion in liboil? Thanks ??? M -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature.asc Type: application/pgp-signature Size: 665 bytes Desc: OpenPGP digital signature URL: From jcupitt at gmail.com Mon Apr 15 09:02:33 2024 From: jcupitt at gmail.com (jcupitt at gmail.com) Date: Mon, 15 Apr 2024 10:02:33 +0100 Subject: Muliply vector by vector? In-Reply-To: <1f13b998-df89-4e3a-a7c4-358b8e9fef3d@gmail.com> References: <1f13b998-df89-4e3a-a7c4-358b8e9fef3d@gmail.com> Message-ID: Hello Martin! How are you, long time no see etc. I used to use orc for this: https://github.com/GStreamer/orc Another possibility is the auto-vectorisation in gcc and clang at O3 and above. It'll vectorise loops like this pretty well: float *restrict p1 = input array float *restrict p2 = second input array float *restrict q = output array for (int i = 0; i < N; i++) q[i] = p1[i] * p2[i]; gcc also supports fixed length vectors, though they are harder to use. I've been using highway recently, it's pretty nice: https://github.com/google/highway It's C++, but you can pretend it's C. John On Mon, 15 Apr 2024 at 04:52, Martin Guy wrote: > > If often have to multiply one array of floats each element with the > corresponding one in another array of floats and store the result in a > third array, mostly to apply window functions to audio fragments. Can > liboil help? The closest things I see in the Liboil Reference Manual > that seems close multiply an array by a constant and put the result in > another array. Am I missing something? Might this be a good candidate > for inclusion in liboil? > > > Thanks > > > M > From martinwguy at gmail.com Mon Apr 15 19:00:27 2024 From: martinwguy at gmail.com (Martin Guy) Date: Mon, 15 Apr 2024 21:00:27 +0200 Subject: Muliply vector by vector? In-Reply-To: References: <1f13b998-df89-4e3a-a7c4-358b8e9fef3d@gmail.com> Message-ID: <6eff495d-9499-4dbf-8c70-1d09857b7d4b@gmail.com> Il 15/04/24 11:02, jcupitt at gmail.com ha scritto: > Hello Martin! How are you, long time no see etc. Hey John! It's been a while... > https://github.com/GStreamer/orc > Another possibility is the auto-vectorisation in gcc and clang at O3 > https://github.com/google/highway Thanks, I'll look further at all three, depending on various constraints like portability and the potential speed gain. I must be getting out of date ;-) Blessings ???? M -------------- next part -------------- A non-text attachment was scrubbed... Name: OpenPGP_signature.asc Type: application/pgp-signature Size: 665 bytes Desc: OpenPGP digital signature URL: