Memory & CPU Caches

This week and last weekend I was primarily focusing on memory pools, allocators, CPU caches. I now probably know how allocators work, simply separating memory allocation & objects initialization, for example, reserve() function in std::vector, it doesn’t initialize the allocated data segment, thus permitting better performance when we don’t need initialize the data immediately.

CPU cache is another very interesting & important aspect that can (hugely) influence the performance of our programs, as it’s way faster than main memory (RAM). Smaller is faster. A great resource I found on Tuesday evening was a YouTube video – Scott Meyers’s presentation on code::drive conference 2014, a very humorous & high-quality speech!! Really awesome!

Here are a few slides screenshots, the complete presentation pdf version can be downloaded from here.

There are some interesting tops contained within it: cache lines, false sharing, data-oriented design, etc. Very practical and constructive.

From Wednesday and later, I reviewed my qsort vs std::sort problem in terms of cpu cache and cache lines. I found a hug bug (typo) in my qsort function call (embarrassed). Then I further developed that, added a few more tests (for instance, indirect sort), and drew some charts. The details can be found here.

Supplemented on Nov 24, 2020

About cache associativity: see, a very detailed & intuitive demonstration.

Additional resource: Gallery of Processor Cache Effects by Igor Ostrovsky.

Completing in Communication

This week I had a discussion about error estimates for FEM with Miss White on Wednesday evening. While in communication about our ideas, I found a few things that I had deemed almost perfect, but it turned out that it was never meant to be perfect if you don’t have an in-depth discussion with someone of your profession yet. As well as subsequent interchange of ideas, we inspired and completed each other in the process of communication in an unconscious way.

Reviewing FEM

This week did actually only one thing, reviewing FEM. I found a lot of C++ numerical libraries, as well as some with FEM, like deal.II, MFEM, FreeFEM. FEM is soooo important in engineering, geophysics, CAD, etc. FEM is fun & powerful.

Thanks to Miss White, I could go over the knowledge in respect to numerical analysis and FEM again. Meanwhile, I want to apologize to Miss White that I didn’t prepare at all for how to teach her programming. Plus I don’t actually use MATLAB much. I’m working on C++, Linux stuff, etc. Truly sorry about that.

Next week, I’m planning to work on some string algorithms (trie, data compression), as well as Computer Vision (which is gonna take a few coming weeks).

Letter To Miss White

Hey, Miss White, how U doin’? It’s quite conflicting whether to write this to ya. (Well, I suck in writing, in turn, there might be some words won’t make sense. So please don’t mind ^_@ )

Last Friday (Oct 2) was really an exceptional day, the whole thing was like a dream, I’d never imagined I could hang out with one of my favorite girls (also my crush) for a whole day. Words failed me. Altogether the time being with you was incredible. But the interesting thing was the day before I was soooo feared, that what if you don’t like there, or don’t like rowing, or whatever. I’m just afraid of upsetting you, which is the last thing I wanna do. I would try everything to make you happy 😉 … I think I’m just in the middle of falling in love with YOU, and I can’t help thinking about YOU all the time. To me, you are perfect. I know it’s way too soon, and this isn’t love. But I need to tell you something: I really really really really really really like you. And I want you, do you want me, do you want me, too.

——- October 22 ——-

I’m always holding the view that people who are told that they’re being loved are happier than those who are not. So I want to be sincere in my feelings and tell you: I LIKE YOU, REALLY REALLY DO.

Actually, you’ve been one of my favourite girls since the first time I saw you when I was trying to audit on an exercise class of mathematical analysis after the major-transferring exam. You were just way too prominent, tall, gorgeous, adorable, a very lovely girl.. And you took all my atention, in turn, I didn’t really listen into anything, but merely remembered one incredible girl that I’d a huge crush on, who was also the only girl I had an image for after the end of the class. It was YOU – Miss White. I’m tickled pink to see you.

I just want to tell you I’M SO INTO YOU. YOU’RE MY LOBSTER. Every minute being with you was peerless. You mean everything to me.