Today's SO -
tl;dr: don't use aliases, just make them functions.
When writing dynamic code, timing (of interpolation) is everything.
Bash stole this person's $1 intended as an AWK variable, resulting in broken code.
https://lnkd.in/eRxNB6FH
#day 65 of #180daysofcode
pointers with character,arrays and functions
#day 66 of #180daysofcode
✅double pointers and multiple pointers in c++
#day 67 of #180daysofcode
memory management:-
🎯static memory location and dynamic memory location
#day 68,69,70 of #180daysofcode
revised previous topic and questions
#day 71 of #180daysofcode
✅2-D and 3-D Arrays dynamic memory location
I wrote 2 more blog posts, one to demonstrate the use of conditional_variable and mutex, the other to demonstrate the use of atomic class in C++.
Conditional_variable and mutex are often used to synchronize threads by blocking a current thread until other threads notify of when a condition is met.
It turns out that using variable or flags, declared as atomic, could achieve the same result. Using atomic is also less expensive.
Link1: https://lnkd.in/ghtsF_qB
Link2: https://lnkd.in/gQXXQESg
A helpful thing that I picked up from the book "Effective Modern C++"
A look at Bootlin contributions from last week:
- Alexis Lothoré continued to work on OpenEmbedded CI/QA tooling, with a v3 of his series "testimage: enable artifacts retrieval for failed tests" (https://lnkd.in/eiukeKbp), and a new patch "patchtest-send-results: prevent false positives due to commit subject" (https://lnkd.in/espc8i79)
- Théo Lebrun was on fire last week in terms of Linux kernel contributions, with a v2 and then v3 of his "spi: cadence-qspi: Fix runtime PM and system-wide suspend" series (https://lnkd.in/euVfZkua), a v5 of his series adding support for the Mobileye system controller (https://lnkd.in/e39FXJ2W), and several new patches/series: "spi: cadence-quadspi: correct chip-select logic" (https://lnkd.in/eNbcETyw) and "spi: spi-mem: add statistics support to ->exec_op() calls" (https://lnkd.in/ePrARuYY)
- Louis Chauvet also worked on SPI, with "Add multi mode support for omap-mcspi" (https://lnkd.in/eri6HTeZ)
- Grégory Clement submitted the 7th iteration of the base support for Mobileye EyeQ5 processors, which looks almost good to be merged based on the feedback received: https://lnkd.in/ehqZMbUq
- Herve Codina sent the 3rd iteration of his series "QMC HDLC", which brings support for HDLC data transfer using the PowerPC QMC hardware block: https://lnkd.in/eTZmaRu9
- Köry Maincent sent the v3 of his series adding support for Power over Ethernet in the Linux kernel: https://lnkd.in/edC9Ay47. We had mistakenly pointed this series in our previous report, but in fact he had been sent only for internal review within Bootlin, now it has been sent externally.
- Finally, Thomas Petazzoni submitted a small update in Buildroot to upgrade the util-linux package: https://lnkd.in/eEsWvwzE
As I am checking out C++26 features, I am excited on how much scientific code could be rewritten with tools coming directly from C++ such as "<linalg>: A free function linear algebra interface based on the BLAS"
🤗
https://lnkd.in/eNWDhTm2
Don't forget about the -v for verbose output from your command lines.
If you're debugging your ROS 2 topics, you can use
ros2 topic info -v <topic_name>
to not just find out how many publishers or subscribers there are, but to see what their node names are too!
Read this post and more on my Typeshare Social Blog: https://lnkd.in/e6GJFBWf
A surprise of the day.
I've recently dropped a post about "The confusion of the day" (https://lnkd.in/d4Jrpzth) about a simple C++ program to calculate matrix determinant.
Crime solved: there was a memory leak when using a half-baked smart/naked pointers + recursive algorithm. Much obliged to https://lnkd.in/dXTqiFmN for the useful hints.
It appears that the straight-forward Laplace's method of crossing out rows and cols (like in school, huh?) and finding determinants of smaller matrices is not quite efficient: O(n!), that's why I was waiting for ~50 seconds to get my determinant of 12x12 matrix. LU decomposition takes only O(n^3) and needs no recursion or spawning extra objects (8 seconds for 1000x1000 matrix, sic!).
I tried 3 approaches: C++ with a matrix made of naked pointers, C++ with unique pointers instead, a fortran program with pretty much similar approach.
The results are interesting: in case of smaller matrices (50x50) all of them behave about the same: it takes almost a second to calculate the determinant for all three, and I bet (to lazy to confirm) most of this time is consumed by a shell wrapper + reading from file.
When we start playing with larger matrices (e.g. 1000x1000) the party gets fancier:
1) C++ and naked pointers: ~8 seconds and ~8 MB of heap.
2) C++ and std::unique_ptrs: ~170 seconds and ~8 MB of heap.
3) fortran: ~13 seconds and ~8 MB of heap.
Apparently, 8 MB comes from holding an entire matrix in the heap memory: 8 bytes per each cell (double precision) multiplied by 1000 rows and 1000 columns.
The major difference between #1 and #2 is accessing (read and write) matrix cells represented via naked pointers vs accessing the same values, but via std::unique_ptr. In our case it's ~20 times slower on avg.
Why? The rumors state that unique pointers offer "little to no overhead compared to the inbuilt ones".
Seriously, why?
source code: https://lnkd.in/d2r3yTwD
Confusion of the day: wrote a simple C++ program to calculate matrix determinants.
1) When using raw pointers to 2D arrays the 10x10 matrix determinant is being calculated on my laptop in ~0.5 secs and eats ~3-4MB RAM.
2) However, when moving to smart pointers (e.g. std::shared_ptr) the same determinant takes ~2 secs and ~85 MB RAM to be calculated.
Isn't it suspicious? I wonder if I'm either using smart pointers poorly or measuring memory (and time) usage incorrectly. Is it possible that simply switching from raw pointers to smart ones would impact resource consumption so significantly?
Code differences between #1 and #2: https://lnkd.in/dn7gtF_7
How to identify the filetype in "ls -l <filename>" command ?
Look at the first character in the command output.
For more details on filetype please check my previous post.