From 24072f26ca10d641c5aa14f8f01ee34ff410d74a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 1 May 2021 19:56:23 -0400 Subject: [PATCH 1/7] ci: Update the image to Fedora 34 This is in preparation to using mutter --headless for tests. --- .gitlab-ci.yml | 4 ++-- .gitlab-ci/fedora.Dockerfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 59dc2e6fec..9bb30b979d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -24,9 +24,9 @@ variables: BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true" FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled" MESON_TEST_TIMEOUT_MULTIPLIER: 3 - FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v29" + FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v30" FLATPAK_IMAGE: "registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master" - DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v29" + DOCS_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v30" .only-default: only: diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile index 6f24276c04..660268261e 100644 --- a/.gitlab-ci/fedora.Dockerfile +++ b/.gitlab-ci/fedora.Dockerfile @@ -1,4 +1,4 @@ -FROM fedora:33 +FROM fedora:34 RUN dnf -y install \ adwaita-icon-theme \ From 014fb414482f586715d6f3c8ea79a64063e9ea26 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 1 May 2021 20:21:54 -0400 Subject: [PATCH 2/7] Help the compiler out gcc says: error: iteration 2147483649 invokes undefined behavior [-Werror=aggressive-loop-optimizations] which of course, never happens because ncols is always >= 2. Add some assertions to tell the compiler. --- demos/gtk-demo/singular_value_decomposition.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/demos/gtk-demo/singular_value_decomposition.c b/demos/gtk-demo/singular_value_decomposition.c index e6d063ab4b..3dafb36242 100644 --- a/demos/gtk-demo/singular_value_decomposition.c +++ b/demos/gtk-demo/singular_value_decomposition.c @@ -2,6 +2,7 @@ #include #include #include +#include /* See Golub and Reinsch, * "Handbook for Automatic Computation vol II - Linear Algebra", @@ -39,6 +40,9 @@ householder_reduction (double *A, double *pu, *pui, *pv, *pvi; double half_norm_squared; + assert (nrows >= 2); + assert (ncols >= 2); + memcpy (U, A, sizeof (double) * nrows * ncols); diagonal[0] = 0.0; @@ -205,6 +209,9 @@ givens_reduction (int nrows, int rotation_test; int iteration_count; + assert (nrows >= 2); + assert (ncols >= 2); + for (i = 0, x = 0.0; i < ncols; i++) { y = fabs (diagonal[i]) + fabs (superdiagonal[i]); @@ -342,6 +349,9 @@ sort_singular_values (int nrows, double temp; double *p1, *p2; + assert (nrows >= 2); + assert (ncols >= 2); + for (i = 0; i < ncols - 1; i++) { max_index = i; @@ -433,9 +443,12 @@ singular_value_decomposition_solve (double *U, double d; double tolerance; + assert (nrows >= 2); + assert (ncols >= 2); + tolerance = DBL_EPSILON * S[0] * (double) ncols; - for ( i = 0, pv = V; i < ncols; i++, pv += ncols) + for (i = 0, pv = V; i < ncols; i++, pv += ncols) { x[i] = 0.0; for (j = 0; j < ncols; j++) From 3591da517a03591586da8157bd5142846d737680 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 1 May 2021 21:02:08 -0400 Subject: [PATCH 3/7] Disable another font-challenged reftest --- testsuite/reftests/meson.build | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/testsuite/reftests/meson.build b/testsuite/reftests/meson.build index a8ef4b48bc..f2dc31e570 100644 --- a/testsuite/reftests/meson.build +++ b/testsuite/reftests/meson.build @@ -133,7 +133,7 @@ testdata = [ 'border-image-url-scaled.ref.ui', 'border-image-url-scaled.ui', # this seems to make assumptions on text positioning - # that are not valid with subpixel positioning + # that are not valid with subpixel positioning #'border-image-url.css', #'border-image-url.ref.ui', #'border-image-url.ui', @@ -324,8 +324,10 @@ testdata = [ 'label-text-shadow-changes-modify-clip.ui', 'label-width-chars-dont-shrink.ref.ui', 'label-width-chars-dont-shrink.ui', - 'label-wrap-justify.ref.ui', - 'label-wrap-justify.ui', + # this seems to make assumptions on text positioning + # that are not valid with subpixel positioning + #'label-wrap-justify.ref.ui', + #'label-wrap-justify.ui', 'letter-spacing.css', 'letter-spacing.ui', 'letter-spacing.ref.ui', From bafa23fa2ccbaddbaf7235a63c0fca72fc64c461 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 May 2021 15:41:46 -0400 Subject: [PATCH 4/7] Add debug spew to gdk tests --- testsuite/gdk/gdk.test.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/gdk/gdk.test.in b/testsuite/gdk/gdk.test.in index 9784de8542..b766ceb9b6 100644 --- a/testsuite/gdk/gdk.test.in +++ b/testsuite/gdk/gdk.test.in @@ -1,4 +1,4 @@ [Test] -Exec=/bin/sh -c "env G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose" +Exec=/bin/sh -c "env GDK_DEBUG=clipboard G_ENABLE_DIAGNOSTIC=0 GTK_A11Y=test @testexecdir@/@test@ --tap -k --verbose" Type=session Output=TAP From de056a3319151f7e7e7183057ed4e0815daa3b8b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 May 2021 16:22:32 -0400 Subject: [PATCH 5/7] ci: Show OS release for our containers --- .gitlab-ci.yml | 5 ++++- .gitlab-ci/show-info-linux.sh | 5 +++++ .../{show-execution-environment.sh => show-info-osx.sh} | 0 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100755 .gitlab-ci/show-info-linux.sh rename .gitlab-ci/{show-execution-environment.sh => show-info-osx.sh} (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9bb30b979d..6b863c5507 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -77,6 +77,7 @@ fedora-x86_64: variables: EXTRA_MESON_FLAGS: "--buildtype=debug --default-library=both" script: + - .gitlab-ci/show-info-linux.sh - meson subprojects update - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS} _build @@ -92,6 +93,7 @@ release-build: variables: EXTRA_MESON_FLAGS: "--buildtype=release" script: + - .gitlab-ci/show-info-linux.sh - meson subprojects update - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS} _build @@ -106,6 +108,7 @@ installed-tests: EXTRA_MESON_FLAGS: "--prefix=/usr --libdir=/usr/lib64 -Dinstall-tests=true" G_TEST_ACCESSIBLE: 1 script: + - .gitlab-ci/show-info-linux.sh - meson subprojects update - meson ${COMMON_MESON_FLAGS} ${EXTRA_MESON_FLAGS} ${BACKEND_FLAGS} ${FEATURE_FLAGS} _build @@ -155,7 +158,7 @@ macos: - macos needs: [] before_script: - - bash .gitlab-ci/show-execution-environment.sh + - bash .gitlab-ci/show-info-osx.sh - pip3 install --user meson==0.56 - pip3 install --user ninja - export PATH=/Users/gitlabrunner/Library/Python/3.7/bin:$PATH diff --git a/.gitlab-ci/show-info-linux.sh b/.gitlab-ci/show-info-linux.sh new file mode 100755 index 0000000000..b0d9ff317e --- /dev/null +++ b/.gitlab-ci/show-info-linux.sh @@ -0,0 +1,5 @@ +#! /bin/sh + +. /etc/os-release + +echo $PRETTY_NAME diff --git a/.gitlab-ci/show-execution-environment.sh b/.gitlab-ci/show-info-osx.sh similarity index 100% rename from .gitlab-ci/show-execution-environment.sh rename to .gitlab-ci/show-info-osx.sh From 399fb766522095136132c5ced7d19ae654ce97e6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 May 2021 16:31:03 -0400 Subject: [PATCH 6/7] ci: Add pygobject to the images This will let us add introspection tests in the future. --- .gitlab-ci/fedora.Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile index 660268261e..4d7937286d 100644 --- a/.gitlab-ci/fedora.Dockerfile +++ b/.gitlab-ci/fedora.Dockerfile @@ -73,6 +73,7 @@ RUN dnf -y install \ pcre-devel \ pcre-static \ python3 \ + python3-gobject \ python3-jinja2 \ python3-markdown \ python3-pip \ From 930ff499ee25d8606c6ca0b00084dea3ac0d1fd9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 5 May 2021 18:58:23 -0400 Subject: [PATCH 7/7] Confine -mf16c to a single source file We can't use this flag for any code that may get run outside the __builtin_cpu_supports() check, and meson doesn't allow per-file cflags. So we have to split this code off into its own static library. --- gsk/meson.build | 17 +++++++++++++- gsk/ngl/fp16.c | 39 ++++--------------------------- gsk/ngl/fp16i.c | 53 +++++++++++++++++++++++++++++++++++++++++++ gsk/ngl/fp16private.h | 6 +++++ meson.build | 3 ++- 5 files changed, 82 insertions(+), 36 deletions(-) create mode 100644 gsk/ngl/fp16i.c diff --git a/gsk/meson.build b/gsk/meson.build index f351941c22..7b82108286 100644 --- a/gsk/meson.build +++ b/gsk/meson.build @@ -88,6 +88,10 @@ gsk_private_sources = files([ 'ngl/fp16.c', ]) +gsk_f16c_sources = files([ + 'ngl/fp16i.c', +]) + gsk_public_headers = files([ 'gskcairorenderer.h', 'gskenums.h', @@ -209,6 +213,17 @@ gsk_deps = [ libgdk_dep, ] +libgsk_f16c = static_library('gsk_f16c', + sources: gsk_f16c_sources, + dependencies: gsk_deps, + include_directories: [ confinc, ], + c_args: [ + '-DGTK_COMPILATION', + '-DG_LOG_DOMAIN="Gsk"', + '-DG_LOG_STRUCTURED=1', + ] + common_cflags + f16c_cflags, +) + libgsk = static_library('gsk', sources: [ gsk_public_sources, @@ -223,7 +238,7 @@ libgsk = static_library('gsk', '-DG_LOG_DOMAIN="Gsk"', '-DG_LOG_STRUCTURED=1', ] + common_cflags, - link_with: libgdk, + link_with: [ libgdk, libgsk_f16c] ) # We don't have link_with: to internal static libs here on purpose, just diff --git a/gsk/ngl/fp16.c b/gsk/ngl/fp16.c index 1e11faafd8..100d13e997 100644 --- a/gsk/ngl/fp16.c +++ b/gsk/ngl/fp16.c @@ -18,14 +18,10 @@ * SPDX-License-Identifier: LGPL-2.1-or-later */ -#include +#include "config.h" #include "fp16private.h" -#ifdef HAVE_F16C -#include -#endif - static inline guint as_uint (const float x) { @@ -80,33 +76,6 @@ half_to_float4_c (const guint16 h[4], #ifdef HAVE_F16C -#if defined(_MSC_VER) && !defined(__clang__) -#define CAST_M128I_P(a) (__m128i const *) a -#else -#define CAST_M128I_P(a) (__m128i_u const *) a -#endif - -static void -float_to_half4_f16c (const float f[4], - guint16 h[4]) -{ - __m128 s = _mm_loadu_ps (f); - __m128i i = _mm_cvtps_ph (s, 0); - _mm_storel_epi64 ((__m128i*)h, i); -} - -static void -half_to_float4_f16c (const guint16 h[4], - float f[4]) -{ - __m128i i = _mm_loadl_epi64 (CAST_M128I_P (h)); - __m128 s = _mm_cvtph_ps (i); - - _mm_store_ps (f, s); -} - -#undef CAST_M128I_P - #if defined(_MSC_VER) && !defined(__clang__) /* based on info from https://walbourn.github.io/directxmath-f16c-and-fma/ */ static gboolean @@ -154,6 +123,7 @@ half_to_float4 (const guint16 h[4], float f[4]) } #else + void float_to_half4 (const float f[4], guint16 h[4]) __attribute__((ifunc ("resolve_float_to_half4"))); void half_to_float4 (const guint16 h[4], float f[4]) __attribute__((ifunc ("resolve_half_to_float4"))); @@ -176,9 +146,10 @@ resolve_half_to_float4 (void) else return half_to_float4_c; } + #endif -#else +#else /* ! HAVE_F16C */ #if defined(__APPLE__) || (defined(_MSC_VER) && !defined(__clang__)) // turns out aliases don't work on Darwin nor Visual Studio @@ -204,4 +175,4 @@ void half_to_float4 (const guint16 h[4], float f[4]) __attribute__((alias ("half #endif -#endif /* GTK_HAS_F16C */ +#endif /* HAVE_F16C */ diff --git a/gsk/ngl/fp16i.c b/gsk/ngl/fp16i.c new file mode 100644 index 0000000000..74c5827ff8 --- /dev/null +++ b/gsk/ngl/fp16i.c @@ -0,0 +1,53 @@ +/* fp16i.c + * + * Copyright 2021 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program. If not, see . + * + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +#include "config.h" + +#include "fp16private.h" + +#ifdef HAVE_F16C +#include + +#if defined(_MSC_VER) && !defined(__clang__) +#define CAST_M128I_P(a) (__m128i const *) a +#else +#define CAST_M128I_P(a) (__m128i_u const *) a +#endif + +void +float_to_half4_f16c (const float f[4], + guint16 h[4]) +{ + __m128 s = _mm_loadu_ps (f); + __m128i i = _mm_cvtps_ph (s, 0); + _mm_storel_epi64 ((__m128i*)h, i); +} + +void +half_to_float4_f16c (const guint16 h[4], + float f[4]) +{ + __m128i i = _mm_loadl_epi64 (CAST_M128I_P (h)); + __m128 s = _mm_cvtph_ps (i); + + _mm_store_ps (f, s); +} + +#endif /* HAVE_F16C */ diff --git a/gsk/ngl/fp16private.h b/gsk/ngl/fp16private.h index d76f18a04f..a2c53d6c2d 100644 --- a/gsk/ngl/fp16private.h +++ b/gsk/ngl/fp16private.h @@ -35,6 +35,12 @@ void float_to_half4 (const float f[4], void half_to_float4 (const guint16 h[4], float f[4]); +void float_to_half4_f16c (const float f[4], + guint16 h[4]); + +void half_to_float4_f16c (const guint16 h[4], + float f[4]); + G_END_DECLS #endif diff --git a/meson.build b/meson.build index d8660cbe85..9ae976d40a 100644 --- a/meson.build +++ b/meson.build @@ -728,7 +728,8 @@ int main () { if cc.compiles(f16c_prog, args: test_f16c_cflags, name: 'F16C intrinsics') cdata.set('HAVE_F16C', 1) f16c_cflags = test_f16c_cflags - common_cflags += test_f16c_cflags + else + f16c_cflags = [] endif endif