Coder Social home page Coder Social logo

Comments (9)

EleonoreMizo avatar EleonoreMizo commented on August 16, 2024

Thanks for the report. In src/conc/Interlocked.hpp, line 328, could you try to replace:

	static_assert (
		__atomic_always_lock_free (sizeof (dest), nullptr),
		"128-bit atomic operations are not lock-free"
	);
	old = comp;
	__atomic_compare_exchange_n (
		&dest, &old, excg,
		false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST
	);

with:

	old = __sync_val_compare_and_swap (&dest, comp, excg);

and tell me if it works better? Thanks

You could also try with clang: configure --enable-clang

from fmtconv.

marillat avatar marillat commented on August 16, 2024

This patch is correct ? If yes this doesn't build. See the build error after the patch ?

--- fmtconv-dmo-27.orig/src/conc/Interlocked.hpp
+++ fmtconv-dmo-27/src/conc/Interlocked.hpp
@@ -325,7 +325,7 @@ void        Interlocked::cas (Data128 &old, vol
 
 #elif defined (__GNUC__)
 
-       static_assert (
+       old = __sync_val_compare_and_swap (&dest, comp, excg);
                __atomic_always_lock_free (sizeof (dest), nullptr),
                "128-bit atomic operations are not lock-free"
        );

GCC output.

libtool: compile:  g++ -DPACKAGE_NAME=\"fmtconv\" -DPACKAGE_TARNAME=\"fmtconv\" -DPACKAGE_VERSION=\"r27\" "-DPACKAGE_STRING=\"fmtconv r27\"" "-DPACKAGE_BUGREPORT=\"http://forum.doom9.org/showthread.php?t=166504\"" "-DPACKAGE_URL=\"http://forum.doom9.org/showthread.php?t=166504\"" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -Wdate-time -D_FORTIFY_SOURCE=2 -std=c++14 -O3 -g3 -DNDEBUG -mfpmath=sse -msse2 -mcx16 -Wall -Wextra -Wshadow -Wunused -Wnull-dereference -Wvla -Wstrict-aliasing -Wuninitialized -Wunused-parameter -Wreorder -Wsign-compare -Wunreachable-code -Wconversion -Wno-sign-conversion -Wredundant-decls -Wno-ignored-attributes -Wno-expansion-to-defined -I./../../src -g -O2 -ffile-prefix-map=/home/marillat/src/fmtconv-27=. -fstack-protector-strong -Wformat -Werror=format-security -c ../../src/fmtcl/Dither.cpp  -fPIC -DPIC -o ../../src/fmtcl/.libs/Dither.o
In file included from ./../../src/conc/Interlocked.h:132,
                 from ./../../src/conc/AtomicPtr.hpp:27,
                 from ./../../src/conc/AtomicPtr.h:123,
                 from ./../../src/conc/CellPool.h:30,
                 from ./../../src/conc/ObjPool.h:44,
                 from ./../../src/fmtcl/Dither.h:26,
                 from ../../src/fmtcl/Dither.cpp:29:
./../../src/conc/Interlocked.hpp: In static member function 'static void conc::Interlocked::cas(conc::Interlocked::Data128&, volatile Data128&, const Data128&, const Data128&)':
./../../src/conc/Interlocked.hpp:329:43: warning: left operand of comma operator has no effect [-Wunused-value]
  329 |                 __atomic_always_lock_free (sizeof (dest), nullptr),
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
./../../src/conc/Interlocked.hpp:330:62: error: expected ';' before ')' token
  330 |                 "128-bit atomic operations are not lock-free"
      |                                                              ^
      |                                                              ;
  331 |         );
      |         ~                                                     
./../../src/conc/Interlocked.hpp:331:10: warning: right operand of comma operator has no effect [-Wunused-value]
  331 |         );
      |          ^
make: *** [Makefile:1779: ../../src/fmtcl/Dither.lo] Error 1

from fmtconv.

marillat avatar marillat commented on August 16, 2024

Well me be the patch is supposed to be this one ?

--- a/src/conc/Interlocked.hpp
+++ b/src/conc/Interlocked.hpp
@@ -325,15 +325,7 @@ void	Interlocked::cas (Data128 &old, vol
 
 #elif defined (__GNUC__)
 
-	static_assert (
-		__atomic_always_lock_free (sizeof (dest), nullptr),
-		"128-bit atomic operations are not lock-free"
-	);
-	old = comp;
-	__atomic_compare_exchange_n (
-		&dest, &old, excg,
-		false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST
-	);
+	old = __sync_val_compare_and_swap (&dest, comp, excg);
 
 #else

from fmtconv.

EleonoreMizo avatar EleonoreMizo commented on August 16, 2024

Yes, the second one.

from fmtconv.

marillat avatar marillat commented on August 16, 2024

This fix this issue for amd64, arm64, armhf and i 86 arches but fail with armel for gcc and clang.

libtool: compile:  clang++ -DPACKAGE_NAME=\"fmtconv\" -DPACKAGE_TARNAME=\"fmtconv\" -DPACKAGE_VERSION=\"r27\" "-DPACKAGE_STRING=\"fmtconv r27\"" "-DPACKAGE_BUGREPORT=\"http://forum.doom9.org/showthread.php?t=166504\"" "-DPACKAGE_URL=\"http://forum.doom9.org/showthread.php?t=166504\"" -DHAVE_STDIO_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_STRINGS_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_UNISTD_H=1 -DSTDC_HEADERS=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -Wdate-time -D_FORTIFY_SOURCE=2 -std=c++14 -O3 -g3 -DNDEBUG -ftree-vectorize -mfpu=neon -Wall -Wextra -Wshadow -Wunused -Wnull-dereference -Wvla -Wstrict-aliasing -Wuninitialized -Wunused-parameter -Wreorder -Wsign-compare -Wunreachable-code -Wconversion -Wno-sign-conversion -Wshadow-all -Wshorten-64-to-32 -Wint-conversion -Wconditional-uninitialized -Wconstant-conversion -Wunused-private-field -Wbool-conversion -Wextra-semi -Wnullable-to-nonnull-conversion -Wno-unused-private-field -Wno-unused-command-line-argument -I./../../src -g -O2 -ffile-prefix-map=/home/marillat/fmtconv-dmo-27=. -fstack-protector-strong -Wformat -Werror=format-security -c ../../src/fmtcl/Dither.cpp  -fPIC -DPIC -o ../../src/fmtcl/.libs/Dither.o
In file included from ../../src/fmtcl/Dither.cpp:29:
In file included from ./../../src/fmtcl/Dither.h:26:
In file included from ./../../src/conc/ObjPool.h:44:
In file included from ./../../src/conc/CellPool.h:33:
In file included from ./../../src/conc/LockFreeStack.h:45:
In file included from ./../../src/conc/AtomicPtrIntPair.h:40:
In file included from ./../../src/conc/Interlocked.h:132:
./../../src/conc/Interlocked.hpp:105:2: error: static_assert failed due to requirement '__atomic_always_lock_free(sizeof (dest), nullptr)' "32-bit atomic operations are not lock-free"
        static_assert (
        ^
./../../src/conc/Interlocked.hpp:223:2: error: static_assert failed due to requirement '__atomic_always_lock_free(sizeof (dest), nullptr)' "64-bit atomic operations are not lock-free"
        static_assert (
        ^
2 errors generated.
make: *** [Makefile:1779: ../../src/fmtcl/Dither.lo] Error 1

from fmtconv.

EleonoreMizo avatar EleonoreMizo commented on August 16, 2024

Thank you so much for the testing. It seems armel architecture doesn’t have lock-free primitives, so I think I’ll just remove the static_assert() so the compiler will make use of the non-lock-free fallback. This will be sub-optimal but should work.

from fmtconv.

marillat avatar marillat commented on August 16, 2024

master commit 3a78392 fail to build for arm64

ERROR: compile ../../src/fmtcl/Dither.cpp on localhost failed
In file included from ./../../src/conc/Interlocked.h:132,
                 from ./../../src/conc/AtomicPtrIntPair.h:40,
                 from ./../../src/conc/LockFreeStack.h:45,
                 from ./../../src/conc/CellPool.h:33,
                 from ./../../src/conc/ObjPool.h:44,
                 from ./../../src/fmtcl/Dither.h:26,
                 from ../../src/fmtcl/Dither.cpp:29:
./../../src/conc/Interlocked.hpp: In static member function 'static void conc::Interlocked::cas(conc::Interlocked::Data128&, volatile Data128&, const Data128&, const Data128&)':
./../../src/conc/Interlocked.hpp:335:51: error: static assertion failed: 128-bit atomic operations are not lock-free
  335 |                         __atomic_always_lock_free (sizeof (dest), nullptr),
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
make: *** [Makefile:1805: ../../src/fmtcl/Dither.lo] Error 1

from fmtconv.

EleonoreMizo avatar EleonoreMizo commented on August 16, 2024

The hell… Is 86d5b90 better?

from fmtconv.

marillat avatar marillat commented on August 16, 2024

Yes, build for all arches.

from fmtconv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.