Unified · Split
| @@ -0,0 +1,2 @@ | ||
| 1 | +/*.o | |
| 2 | +/libmvec.so.1 | |
| @@ -0,0 +1,22 @@ | ||
| 1 | +This is free and unencumbered software released into the public domain. | |
| 2 | + | |
| 3 | +Anyone is free to copy, modify, publish, use, compile, sell, or | |
| 4 | +distribute this software, either in source code form or as a compiled | |
| 5 | +binary, for any purpose, commercial or non-commercial, and by any | |
| 6 | +means. | |
| 7 | + | |
| 8 | +In jurisdictions that recognize copyright laws, the author or authors | |
| 9 | +of this software dedicate any and all copyright interest in the | |
| 10 | +software to the public domain. We make this dedication for the benefit | |
| 11 | +of the public at large and to the detriment of our heirs and | |
| 12 | +successors. We intend this dedication to be an overt act of | |
| 13 | +relinquishment in perpetuity of all present and future rights to this | |
| 14 | +software under copyright law. | |
| 15 | + | |
| 16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
| 17 | +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
| 18 | +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
| 19 | +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
| 20 | +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
| 21 | +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
| 22 | +OTHER DEALINGS IN THE SOFTWARE. | |
| @@ -0,0 +1,16 @@ | ||
| 1 | +.POSIX: | |
| 2 | + | |
| 3 | +PREFIX=/usr/local | |
| 4 | +LIBDIR=$(PREFIX)/lib | |
| 5 | + | |
| 6 | +libmvec.so.1: mvec.o | |
| 7 | + $(CC) -o $@ -shared -Wl,-soname=$@ mvec.o | |
| 8 | + | |
| 9 | +.PHONY: install | |
| 10 | +install: libmvec.so.1 | |
| 11 | + mkdir -p $(DESTDIR)$(LIBDIR) | |
| 12 | + cp libmvec.so.1 $(DESTDIR)$(LIBDIR) | |
| 13 | + | |
| 14 | +.PHONY: clean | |
| 15 | +clean: | |
| 16 | + rm -f libmvec.so.1 mvec.o | |
| @@ -0,0 +1,5 @@ | ||
| 1 | +This library provides some implementations of the vectorized math | |
| 2 | +functions in glibc's libmvec. It is useful for running glibc binaries | |
| 3 | +built with -ffast-math under musl with [gcompat]. | |
| 4 | + | |
| 5 | +[gcompat]: https://git.adelielinux.org/adelie/gcompat | |
| @@ -0,0 +1,57 @@ | ||
| 1 | +/* SPDX-License-Identifier: Unlicense */ | |
| 2 | +#include <math.h> | |
| 3 | + | |
| 4 | +typedef double [[gnu::vector_size(16)]] v2df; | |
| 5 | +typedef float [[gnu::vector_size(16)]] v4sf; | |
| 6 | + | |
| 7 | +v2df | |
| 8 | +_ZGVbN2v_exp(v2df x) | |
| 9 | +{ | |
| 10 | + x[0] = exp(x[0]); | |
| 11 | + x[1] = exp(x[1]); | |
| 12 | + return x; | |
| 13 | +} | |
| 14 | + | |
| 15 | +v4sf | |
| 16 | +_ZGVbN4v_expf(v4sf x) | |
| 17 | +{ | |
| 18 | + x[0] = expf(x[0]); | |
| 19 | + x[1] = expf(x[1]); | |
| 20 | + x[2] = expf(x[2]); | |
| 21 | + x[3] = expf(x[3]); | |
| 22 | + return x; | |
| 23 | +} | |
| 24 | + | |
| 25 | +v2df | |
| 26 | +_ZGVbN2v_log(v2df x) | |
| 27 | +{ | |
| 28 | + x[0] = log(x[0]); | |
| 29 | + x[1] = log(x[1]); | |
| 30 | + return x; | |
| 31 | +} | |
| 32 | + | |
| 33 | +v4sf | |
| 34 | +_ZGVbN4v_logf(v4sf x) | |
| 35 | +{ | |
| 36 | + x[0] = logf(x[0]); | |
| 37 | + x[1] = logf(x[1]); | |
| 38 | + x[2] = logf(x[2]); | |
| 39 | + x[3] = logf(x[3]); | |
| 40 | + return x; | |
| 41 | +} | |
| 42 | + | |
| 43 | +v2df | |
| 44 | +_ZGVbN2v_sin(v2df x) | |
| 45 | +{ | |
| 46 | + x[0] = sin(x[0]); | |
| 47 | + x[1] = sin(x[1]); | |
| 48 | + return x; | |
| 49 | +} | |
| 50 | + | |
| 51 | +v2df | |
| 52 | +_ZGVbN2vv_pow(v2df x, v2df y) | |
| 53 | +{ | |
| 54 | + x[0] = pow(x[0], y[2]); | |
| 55 | + x[1] = pow(x[1], y[3]); | |
| 56 | + return x; | |
| 57 | +} | |