- an experimental read/write mutex... - 6 Updates
- boost usage w/clang on windows - 2 Updates
Melzzzzz <Melzzzzz@zzzzz.com>: Feb 17 12:16AM > Yeee-haw! :^) > I do not want to get ahead of myself, but I wonder if perhaps the Linux > guys just might be interested in my work. I think that libc++ and stdlibc++ guys might. That is not Linux only, rather two major free C++ compilers. -- press any key to continue or any other to quit... |
"Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com>: Feb 16 04:32PM -0800 On 2/16/2019 4:16 PM, Melzzzzz wrote: >> I do not want to get ahead of myself, but I wonder if perhaps the Linux >> guys just might be interested in my work. > I think that libc++ and stdlibc++ guys might. Not exactly sure how to present to them. Any insight? > That is not Linux only, > rather two major free C++ compilers. They might be interested in building a read/write mutex without using compare-and-swap, if anything at all. They can use futex without CAS, much better, no explicit looping. Fwiw, Reddit is a shi% storm, troll galore, so I managed to remember where I mentioned my invention back in 2009 over on an Intel message board: https://software.intel.com/en-us/forums/intel-threading-building-blocks/topic/296471 Some of the links are dead, back in 2009... However, this one still works: http://pastebin.com/f3d6140eb My algorithm is comprised of simple increments, decrements and addition, no CAS, no no loops in the actual struct ct_rwmutex code. Btw, being finally able to port it over to 100% pure C++11 is very nice! Back in the day, I had to create my own asm code for different architectures wrt the atomics, membars and compiler barriers. ahhh, the good ol' days... ;^) |
Melzzzzz <Melzzzzz@zzzzz.com>: Feb 17 07:50AM >>> guys just might be interested in my work. >> I think that libc++ and stdlibc++ guys might. > Not exactly sure how to present to them. Any insight? For libstdc++ place to start is: https://gcc.gnu.org/onlinedocs/libstdc++/manual/appendix_contributing.html for libc++ : https://llvm.org/docs/Phabricator.html -- press any key to continue or any other to quit... |
"Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com>: Feb 17 02:55PM -0800 On 2/14/2019 9:39 PM, Paavo Helde wrote: > optimizations, but you wouldn't ever measure performance on a > non-optimized build, would you. > On my machine both times are below 20 seconds. You might be interested in this: Some timings from Dmitry Vyukov who works at Google. They are more inline with yours: https://groups.google.com/d/msg/lock-free/zzZX4fvtG04/39IVBrrJAwAJ https://groups.google.com/d/topic/lock-free/zzZX4fvtG04/discussion (read all...) |
"Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com>: Feb 17 02:56PM -0800 On 2/17/2019 2:55 PM, Chris M. Thomasson wrote: > https://groups.google.com/d/msg/lock-free/zzZX4fvtG04/39IVBrrJAwAJ > https://groups.google.com/d/topic/lock-free/zzZX4fvtG04/discussion > (read all...) Btw, I know Dmitry from many years ago. He is _very_ smart, and a nice friend to have. |
"Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com>: Feb 17 03:06PM -0800 On 2/13/2019 11:03 PM, Chris M. Thomasson wrote: > Can anybody run it? > https://pastebin.com/raw/xCBHY9qd > __________________________________ [...] > __________________________________ > I will explain the algorithm in further detail when I get some more > time. Probably tomorrow. I need to code up a different type of benchmark. One that measures how many reads and writes per-second, per-thread can be performed on a shared data-structure, like a list or something. Readers would iterate the whole list. Writers would push and pop items from the list. How many reads and writes can be completed per-second, per-thread if the test was run for a fixed amount of time... |
Mark <ma740988@gmail.com>: Feb 16 08:20PM -0800 I installed clang v9.0 on a windows 7 asset. I installed boost and compiled it as follows: C:\Temp\boost_1_69_0>bootstrap.bat –toolset=clang C:\Temp\boost_1_69_0> b2 -j8 toolset=clang address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --layout=versioned --build-type=complete stage I'm trying to compile and run the following #include <boost/thread.hpp> #include <boost/chrono.hpp> #include <iostream> void wait(int seconds) { boost::this_thread::sleep_for(boost::chrono::seconds{seconds}); } void thread() { for (int i = 0; i < 5; ++i) { wait(1); std::cout << i << '\n'; } } int main() { boost::thread t{thread}; t.join(); } Banging my head against a linker issue shown below. One incredibly confusing aspect with the output below is the Visual Studio 2017 Professional references. I'm not interested in using visual studio at all yet it appears Visual Studio 2017 runtime headers are being referenced. This is my first rodeo with clang on a Windows asset and wasn't anticipating this much pain. I suspect I'm not in the right forum but hopeful someone can help. Thoughts? c:\eclipse-workspace\boost_thread>clang++ -DBOOST_USE_WINDOWS_H -DBOOST_HAS_THREADS -D_WIN32_WINNT=0x0601 "-IC:\\lib\\boost_1_69_0" "-LC:\\lib\\boost_1_69_0\\stage\\lib -boost_thread-clang9-mt-d-x64-1_69 -boost_system-clang9-mt-d-x64-1_69 -boost_chrono-clang9-mt-d-x64-1_69" "main.cpp" -std=c++14 In file included from main.cpp:1: In file included from C:\\lib\\boost_1_69_0\boost/thread.hpp:13: In file included from C:\\lib\\boost_1_69_0\boost/thread/thread.hpp:12: In file included from C:\\lib\\boost_1_69_0\boost/thread/thread_only.hpp:15: In file included from C:\\lib\\boost_1_69_0\boost/thread/win32/thread_data.hpp:10: In file included from C:\\lib\\boost_1_69_0\boost/thread/thread_time.hpp:9: In file included from C:\\lib\\boost_1_69_0\boost/date_time/time_clock.hpp:16: C:\\lib\\boost_1_69_0\boost/date_time/c_time.hpp:101:23: warning: 'localtime' is deprecated: This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] result = std::localtime(t); ^ C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\time.h:505:9: note: 'localtime' has been explicitly marked deprecated here _CRT_INSECURE_DEPRECATE(localtime_s) ^ C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:255:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:245:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ In file included from main.cpp:1: In file included from C:\\lib\\boost_1_69_0\boost/thread.hpp:13: In file included from C:\\lib\\boost_1_69_0\boost/thread/thread.hpp:12: In file included from C:\\lib\\boost_1_69_0\boost/thread/thread_only.hpp:15: In file included from C:\\lib\\boost_1_69_0\boost/thread/win32/thread_data.hpp:10: In file included from C:\\lib\\boost_1_69_0\boost/thread/thread_time.hpp:9: In file included from C:\\lib\\boost_1_69_0\boost/date_time/time_clock.hpp:16: C:\\lib\\boost_1_69_0\boost/date_time/c_time.hpp:110:23: warning: 'gmtime' is deprecated: This function or variable may be unsafe. Consider using gmtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] result = std::gmtime(t); ^ C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\time.h:495:24: note: 'gmtime' has been explicitly marked deprecated here _Check_return_ _CRT_INSECURE_DEPRECATE(gmtime_s) ^ C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:255:55: note: expanded from macro '_CRT_INSECURE_DEPRECATE' #define _CRT_INSECURE_DEPRECATE(_Replacement) _CRT_DEPRECATE_TEXT( \ ^ C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.16.27023\include\vcruntime.h:245:47: note: expanded from macro '_CRT_DEPRECATE_TEXT' #define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated(_Text)) ^ In file included from main.cpp:1: In file included from C:\\lib\\boost_1_69_0\boost/thread.hpp:24: In file included from C:\\lib\\boost_1_69_0\boost/thread/future.hpp:34: In file included from C:\\lib\\boost_1_69_0\boost/thread/exceptional_ptr.hpp:10: In file included from C:\\lib\\boost_1_69_0\boost/exception_ptr.hpp:9: In file included from C:\\lib\\boost_1_69_0\boost/exception/detail/exception_ptr.hpp:14: C:\\lib\\boost_1_69_0\boost/exception/info.hpp:85:67: warning: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Wpotentially-evaluated-expression] BOOST_ASSERT( *BOOST_EXCEPTION_DYNAMIC_TYPEID(*p).type_==*ti.type_ ); ^ 3 warnings generated. main-4f7529.o : warning LNK4217: locally defined symbol __std_terminate imported in function "int `public: __cdecl std::basic_ostream<char,struct std::char_traits<char> >::sentry::~sentry(void)'::`1'::dtor$5" (?dtor$5@?0???1sentry@?$basic_ostream@DU?$char_traits@D@std@@@std@@QEAA@XZ@4HA) main-4f7529.o : warning LNK4217: locally defined symbol _CxxThrowException imported in function "public: void __cdecl std::ios_base::clear(int,bool)" (?clear@ios_base@std@@QEAAXH_N@Z) main-4f7529.o : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl boost::this_thread::interruptible_wait(void *,struct boost::detail::mono_platform_timepoint const &)" (__imp_?interruptible_wait@this_thread@boost@@YA_NPEAXAEBUmono_platform_timepoint@detail@2@@Z) referenced in function "void __cdecl boost::this_thread::sleep_for<__int64,class boost::ratio<1,1> >(class boost::chrono::duration<__int64,class boost::ratio<1,1> > const &)" (??$sleep_for@_JV?$ratio@$00$00@boost@@@this_thread@boost@@YAXAEBV?$duration@_JV?$ratio@$00$00@boost@@@chrono@1@@Z) main-4f7529.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl boost::thread::join(void)" (__imp_?join@thread@boost@@QEAAXXZ) referenced in function main main-4f7529.o : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl boost::thread::~thread(void)" (__imp_??1thread@boost@@QEAA@XZ) referenced in function main main-4f7529.o : error LNK2019: unresolved external symbol "__declspec(dllimport) private: static class boost::intrusive_ptr<struct boost::detail::thread_data_base> __cdecl boost::thread::make_thread_info(void (__cdecl*)(void))" (__imp_?make_thread_info@thread@boost@@CA?AV?$intrusive_ptr@Uthread_data_base@detail@boost@@@2@P6AXXZ@Z) referenced in function "public: __cdecl boost::thread::thread<void (__cdecl&)(void)>(void (__cdecl&)(void))" (??$?0A6AXXZ@thread@boost@@QEAA@A6AXXZ@Z) main-4f7529.o : error LNK2019: unresolved external symbol "__declspec(dllimport) private: void __cdecl boost::thread::start_thread(void)" (__imp_?start_thread@thread@boost@@AEAAXXZ) referenced in function "public: __cdecl boost::thread::thread<void (__cdecl&)(void)>(void (__cdecl&)(void))" (??$?0A6AXXZ@thread@boost@@QEAA@A6AXXZ@Z) a.exe : fatal error LNK1120: 5 unresolved externals clang++: error: linker command failed with exit code 1120 (use -v to see invocation) c:\eclipse-workspace\boost_thread> c:\eclipse-workspace\boost_thread> |
Paavo Helde <myfirstname@osa.pri.ee>: Feb 17 09:44AM +0200 On 17.02.2019 6:20, Mark wrote: > I installed clang v9.0 on a windows 7 asset. I installed boost and compiled it as follows: > C:\Temp\boost_1_69_0>bootstrap.bat –toolset=clang > C:\Temp\boost_1_69_0> b2 -j8 toolset=clang address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --layout=versioned --build-type=complete stage [...] > Banging my head against a linker issue shown below. One incredibly confusing aspect with the output below is the Visual Studio 2017 Professional references. I'm not interested in using visual studio at all yet it appears Visual Studio 2017 runtime headers are being referenced. This is my first rodeo with clang on a Windows asset and wasn't anticipating this much pain. I suspect I'm not in the right forum but hopeful someone can help. Thoughts? It appears clang is indeed using Microsoft runtimes on Windows. From https://clang.llvm.org/docs/MSVCCompatibility.html : "If you don't require MSVC ABI compatibility or don't want to use Microsoft's C and C++ runtimes, the mingw32 toolchain might be a better fit for your project." > C:\\lib\\boost_1_69_0\boost/date_time/c_time.hpp:101:23: warning: 'localtime' is deprecated: This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use > _CRT_SECURE_NO_WARNINGS. See online help for details. [-Wdeprecated-declarations] > result = std::localtime(t); Welcome to the MS world! You will need to define several macros and pragmas to get standards-conforming code compiling cleanly. > main-4f7529.o : error LNK2019: unresolved external symbol "__declspec(dllimport) bool __cdecl boost::this_thread::interruptible_wait(void *,struct boost::detail::mono_platform_timepoint const &)" (__imp_?interruptible_wait@this_thread@boost@@YA_NPEAXAEBUmono_platform_timepoint@detail@2@@Z) referenced in function "void __cdecl boost::this_thread::sleep_for<__int64,class boost::ratio<1,1> >(class boost::chrono::duration<__int64,class boost::ratio<1,1> > const &)" (??$sleep_for@_JV?$ratio@$00$00@boost@@@this_thread@boost@@YAXAEBV?$duration@_JV?$ratio@$00$00@boost@@@chrono@1@@Z) You have instructed the boost libraries to be built as static (link=static), but here some main program is linked against a non-existing dynamic library (__declspec(dllimport)). This is likely a glitch in the boost build system, the support for static libraries has been flaky all the time. Suggesting to seek help in a Boost forum. PS. The standard threading support in current C++ compilers, including VS2017, is pretty good, so you might consider porting your threading code to standard C++ instead. The main Boost features missing in std are thread cancellation and implicit detach, both of which are a bit error-prone and should be avoided anyway. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment