by Guest » 20 Jan 2025, 16:44
In Java gibt es eine API namens VectorApi. Es ermöglicht die Durchführung arithmetischer Operationen für ein ganzes float[]-Array in einem einzigen CPU-Zyklus.
Zum Beispiel:
Code: Select all
FloatVector fv = FloatVector.fromArray(SPECIES, new float[]{1, 2, 3, 4, 5, 6, 7}, 0);
//multiplies the wohle array in a single cycle by 2 (if the CPU supports this)
fv.mul(2f);
Jetzt möchte ich das Ergebnis von 1f / FloatVector berechnen. Im Moment mache ich das per
Ich gehe davon aus, dass dies ein langsamer Vorgang sein könnte. Gibt es einen besseren Weg, dies zu tun?
In Java gibt es eine API namens VectorApi. Es ermöglicht die Durchführung arithmetischer Operationen für ein ganzes float[]-Array in einem einzigen CPU-Zyklus.
Zum Beispiel:
[code]FloatVector fv = FloatVector.fromArray(SPECIES, new float[]{1, 2, 3, 4, 5, 6, 7}, 0);
//multiplies the wohle array in a single cycle by 2 (if the CPU supports this)
fv.mul(2f);
[/code]
Jetzt möchte ich das Ergebnis von 1f / FloatVector berechnen. Im Moment mache ich das per
[code]fv.pow(-1f);
[/code]
Ich gehe davon aus, dass dies ein langsamer Vorgang sein könnte. Gibt es einen besseren Weg, dies zu tun?