A Multithreaded, Transaction-Based Locking Strategy for Containersvariable • Atomic pointer • Atomic compare and exchange • Need a class that represents a lockable item (element) • Need a class that manages transactions on behalf of each thread • Transactions are represented Transaction ID using item_id_type = uint64_t; //- Item ID class transaction_manager; class lockable_item; class stopwatch;Copyright © 2020 Bob Steagall Class lockable_item 43 CppCon 2020 - A Multi-threaded Transaction-Based Locking Strategy for Containers Class Overview – lockable_item class lockable_item { public: lockable_item(); item_id_type id() const noexcept; tsv_type last_tsv() const noexcept; private:0 码力 | 142 页 | 474.78 KB | 6 月前3
Writing Python Bindings for C++ Libraries: Easy-to-use Performancecompiled with clang++12 -fPIC -O3Some perf numbers: per increment runtime https://news.ycombinator.com/item?id=34663930 Out in the wild case of noticing high overheads in pysimdjson (they switched from pybind11 print("Row " + str(i) + " is " + str(row)) for item in row.items(): print(" - {}:{}".format(reader.getIdName(item.id), item.value()))Working example $ python3 python/v1.py Number print("Row " + str(i) + " is " + str(row)) for item in row.items(): print(" - {}:{}".format(reader.getIdName(item.id), item.value()))Reader code class RowReader : public BinaryListener0 码力 | 118 页 | 2.18 MB | 6 月前3
Heterogeneous Modern C++ with SYCL 2020com/2021/02/03/can-sycl-slice-into-broader-supercomputing/ https://www.phoronix.com/scan.php?page=news_item&px=hipSYCL-New-Lite-Runtime https://software.intel.com/content/www/us/en/develop/articles/interop itself The kernel function takes as a parameter an id which represents the currently executing work-item #includeint main(int argc, char *argv[]) { std::vector dA{ … }, dB{ … to a work item ○ Not accessible to other work items ○ Kernel memory ○ Local stack variables ● Work item ○ An instance of a kernel ○ Has a global id Work Item Private Memory Work Item Private Memory 0 码力 | 114 页 | 7.94 MB | 6 月前3
C++20 镶 SQLitExample Database Customers id INTEGER PRIMARY KEY name TEXT Orders id INTEGER PRIMARY KEY item TEXT customerid INTEGER price REALCreate the customers table CREATE TABLE customers( id INTEGER INTEGER NOT NULL PRIMARY KEY, item TEXT NOT NULL, customerid INTEGER NOT NULL, price REAL NOT NULL, discount_code TEXT ); Orders id INTEGER PRIMARY KEY item TEXT customerid INTEGER price orders(item , customerid , price, discount_code ) VALUES ("Hoodie",1,10.0,"CppCon"); Id item customerid price discount_code 1 “Hoodie” 1 10.0 CppConQuery for orders SELECT orders.id, name, item, price0 码力 | 46 页 | 775.02 KB | 6 月前3
Building Safe and Reliable Surgical Robotics with C++reduce risk Risk Driven Architecture 26 SW System/Item (Class C) SW Item X (Class C) SW Item Y (Class B) SW Item Z (Class C) SW Item W (Class A) Overcoming Adverse Condition • Faults • Time Domain Risk Driven Architecture 27 SW System/Item (Class C) SW Item X (Class C) SW Item Y (Class B) SW Item Z (Class C) SW Item W (Class A) Non-Real Time • No strict timing guarantees Time Domain Domain Driven Considerations 37 SW System/Item (Class C) SW Item X (Class C) SW Item Y (Class B) SW Item Z (Class C) SW Item W (Class A) Non-Real Time • No strict timing guarantees0 码力 | 71 页 | 4.02 MB | 6 月前3
Expressive Compile-time ParsersParser Generator Overview Grammar Item Sets (states) Parsing tables Image from: “Compilers: Principles, Techniques, and Tools” (dragon book)CTPG – LR(1) Item struct item { int rule; int pos; int int term; };CTPG – LR(1) Item Sets Uses a fixed size bitset constexpr auto rules = sizeof...(Rules); constexpr auto positions = max(Rules.length...) + 1; constexpr auto terms = sizeof...(Terms); constexpr rules * positions * terms; using item_set = bitset;CTPG – LR(1) Item Sets Convert between index and item constexpr uint32_t to_index(item i){ return i.rule * positions * terms 0 码力 | 134 页 | 1.73 MB | 6 月前3
Back to Basics Testing0 ); } SECTION( "Adding to an empty list increases the size to 1" ) { list.add("item1"); REQUIRE( list.empty() == false ); REQUIRE( list.size() == 1 ); } }TEST_CASE( 0 ); } SECTION( "Adding to an empty list increases the size to 1" ) { list.add("item1"); REQUIRE( list.empty() == false ); REQUIRE( list.size() == 1 ); } }TEST_CASE( 0 ); } SECTION( "Adding to an empty list increases the size to 1" ) { list.add("item1"); REQUIRE( list.empty() == false ); REQUIRE( list.size() == 1 ); } }TEST_CASE(0 码力 | 79 页 | 25.86 MB | 6 月前3
The Roles of Symmetry And Orthogonality In Designviolate design symmetry when asymmetry is desired (such as special handling to execute one work item many times) Thread-Stealing Work Queue worker worker worker Work Engine Foo Subsystem A symmetry when asymmetry is desired (such as special handling to execute one work item many times) Orthogonality: Work Item execution (consumption) is unrelated to the producer (e.g., execution is delegated Examples • Designs leveraging orthogonal behavior: Orthogonal Because: Work item creation is “orthogonal” (unrelated) to work item processing Thread-stealing Work Queue: RAII work items transferred to queue0 码力 | 151 页 | 3.20 MB | 6 月前3
Reusable Code & Reusable Data Structuresresults = /* magic */; 5 tc::for_each( 6 tc::zip(results, rng), 7 [](rect r, auto& item) { place(r, item); } 8 ); 9 10 11 12 13 14 } 15 231. DISPATCH TO FUNCTION OVERLOADS void place_items(rect [](rect r, auto& item) { place(r, item); } 8 ); 9 10 11 12 13 14 } 15 void place(rect r, great_widget); void place(rect r, awesome_widget); [](rect r, auto& item) { place(r, item); } 1 2 3 void [](rect r, auto& item) { place(r, item); } 8 ); 9 10 11 12 13 14 } 15 void place(rect r, great_widget); void place(rect r, awesome_widget); [](rect r, auto& item) { place(r, item); } 1 2 3 void0 码力 | 132 页 | 14.20 MB | 6 月前3
Changing Legacy Code: With Confidencetype 'const bark_cnt' (aka 'const unsigned short') // add "potential" bark back *bark_cnt += asset_item->potential_bark_to_ignore; 104 lines later…Reduce scope and const const auto now = timer_function(); Resource bugs void updateColor(ID itemId, Color newColor) { ReserveMutex(&itemMutex); item* itemToChange = get_item_from_id(itemId); if(itemToChange == NULL) { ReleaseMutex(&itemMutex); return; } it Resource bugs void updateColor(ID itemId, Color newColor) { ReserveMutex(&itemMutex); item* itemToChange = get_item_from_id(itemId); if(itemToChange == NULL) { ReleaseMutex(&itemMutex); return; } it0 码力 | 114 页 | 982.54 KB | 6 月前3
共 118 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
相关搜索词
MultithreadedTransactionBasedLockingStrategyforContainersWritingPythonBindingsC++LibrariesEasytousePerformanceHeterogeneousModernwithSYCL202020SQLBuildingSafeandReliableSurgicalRoboticsExpressiveCompiletimeParsersBackBasicsTestingTheRolesofSymmetryAndOrthogonalityInDesignReusableCodeDataStructuresChangingLegacyWithConfidence













