From 95f54eeb404105a71e281745e78be1c86fc23c6f Mon Sep 17 00:00:00 2001 From: Justine Tunney Date: Wed, 10 Aug 2022 12:16:43 -0700 Subject: [PATCH] Release Landlock Make v1.0.1 --- examples/dot.c | 42 +++++++++++++++++++++++++++++++++++++++++ third_party/make/main.c | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 examples/dot.c diff --git a/examples/dot.c b/examples/dot.c new file mode 100644 index 000000000..09d377522 --- /dev/null +++ b/examples/dot.c @@ -0,0 +1,42 @@ +#if 0 +/*─────────────────────────────────────────────────────────────────╗ +│ To the extent possible under law, Justine Tunney has waived │ +│ all copyright and related or neighboring rights to this file, │ +│ as it is written in the following disclaimers: │ +│ • http://unlicense.org/ │ +│ • http://creativecommons.org/publicdomain/zero/1.0/ │ +╚─────────────────────────────────────────────────────────────────*/ +#endif +#include "libc/macros.internal.h" +#include "libc/stdio/stdio.h" + +typedef float xmm_t __attribute__((__vector_size__(16), __aligned__(4))); + +float dotvector(float *x, float *y, size_t n) { + size_t i; + float res; + if (n > 64) { + return dotvector(x, y, n / 2) + dotvector(x + n / 2, y + n / 2, n - n / 2); + } + for (res = i = 0; i < n; ++i) { + if (i + 4 <= n) { + xmm_t res4 = (xmm_t){0}; + do { + res4 += *(xmm_t *)(x + i) * *(xmm_t *)(y + i); + } while ((i += 4) + 4 <= n); + res += res4[0]; + res += res4[1]; + res += res4[2]; + res += res4[3]; + continue; + } + res += x[i] * y[i]; + } + return res; +} + +int main(int argc, char *argv[]) { + float x[] = {1, 2, 3, 4, 1, 2, 3, 4}; + float y[] = {4, 3, 2, 1, 1, 2, 3, 4}; + printf("%g\n", dotvector(x, y, ARRAYLEN(x))); +} diff --git a/third_party/make/main.c b/third_party/make/main.c index db78c19d0..eba98d7d9 100644 --- a/third_party/make/main.c +++ b/third_party/make/main.c @@ -2971,7 +2971,7 @@ print_version (void) /* Do it only once. */ return; - printf ("%sGNU Make %s\n", precede, version_string); + printf ("%sLandlock Make 1.0.1 (GNU Make %s)\n", precede, version_string); if (!remote_description || *remote_description == '\0') printf (_("%sBuilt for %s\n"), precede, make_host);