Daniel Lemire's blog

Avoid lexicographical comparisons when testing for string equality?

, 3 min read

By default, programmers like to compare their bytes and strings using a lexicographical order. “Lexicographical” is a fancy word for “dictionary order”. That is, you compare the first two elements, check if they differ, if they do you report which string is largest, if not you repeat with…

Performance of ranged accesses into arrays: modulo, multiply-shift and masks

, 3 min read

Suppose that you wish to access values in an array of size n, but instead of having indexes in [0,n), you have arbitrary non-negative integers. This sort of problems happen when you build a hash table or other array-backed data structure. The naive approach to this problem is to use the remainder…

Science and Technology links (August 19th, 2018)

, 3 min read

Publishing your ideas is a central component of science and scholarship. To make it easier to publish, some companies and organizations have begun to offer pay-to-publish journals and conferences where pretty much anything can get published. A Canadian economics professor has apparently been…

Fast strongly universal 64-bit hashing everywhere!

, 2 min read

In software, hashing is the process of taking a value and mapping it to a random-looking value. Suppose you are given 64-bit integers (a long in Java). You might want to “hash” these integers to other 64-bit values. There are many good ways to achieve this result, but let me add some…

The dangers of AVX-512 throttling: a 3% impact on Xeon Gold processors?

, 2 min read

Intel’s latest processors come with powerful new instructions from the AVX-512 family. These instructions operate over 512-bit registers. They use more power than regular (64-bit) instructions. Thus, on some Intel processors, the processor core that is using AVX-512 might run at a lower…

Science and Technology links (August 10th, 2018)

, 4 min read

There are far fewer forest fires now than there was 15 years ago. The Earth is getting greener. There are more forests: We show that—contrary to the prevailing view that forest area has declined globally—tree cover has increased by 2.24 million km2 (+7.1% relative to the 1982…

Science and Technology links (August 4th, 2018)

, 2 min read

About 80% of the ocean remains unmapped and unexplored. Even a mild concussion (a fall on your head) can double your risk of dementia (e.g., Alzheimer’s). Apple is selling approximatively two smart watches for each laptop. And they are selling about three iPads for each laptops. (I do not own an…

Getting 4 bytes or a full cache line: same speed or not?

, 3 min read

Many software operations are believed to be “memory bound”, meaning that the processor spins empty while waiting for data to come from memory. To compensate, our processors rely on fast cache memory. If your problem fits in cache, it will typically run much faster than if the processor…

Science and Technology links (July 27th, 2018)

, 2 min read

It is frequently argued that intelligence requires great complexity. But complex compared to what? To put things in perspective, my friend Leonid points out that tiny worms have simple brains and yet they can compute the solution to several problems: C elegans [a common worm] has less than 500…

Writing about software and building software are different jobs

, 2 min read

Code taken from a blog post is meant to illustrate an idea. Blogging is literature, not engineering. Don’t build production systems by copying and pasting random code form the Internet. It will not end well. A reader commented that some of my C code from an earlier blog post is not proper…

It is more complicated than I thought: -mtune, -march in GCC

, 4 min read

My favourite C compilers are GNU GCC and LLVM’s Clang. In C, you compile for some architecture. Thus you have to tell the compiler what kind of machine you have. In theory, you could recompile all the code for the exact machine you have, but it is slow and error prone. So we rely on prebuilt…

Are vectorized random number generators actually useful?

, 1 min read

Our processors benefit from “SIMD” instructions. These instructions can operate on several values at once, thus greatly accelerating some algorithms. Earlier, I reported that you can multiply the speed of common (fast) random number generators such as PCG and xorshift128+ by a factor of three…

Science and Technology links (July 21st, 2018)

, 4 min read

It seems that something called “Cartesian Genetic Programming” could be a match for Deep Learning. If you look at the best paid individuals in most fields, most of them are men. Why is that? There are many possible explanations. One of them is that men take more risks. If you hope to ever get…

Accelerating Conway´s Game of Life with SIMD instructions

, 2 min read

Conway’s Game of Life is one of the simplest non-trivial simulation one can program. It simulates the emergence of life from chaos. Though the rules are simple, the game of life is still being studied for the last five decades. The rules are simple. You have a grid where each cell in the grid has…

Science and Technology links (July 15th, 2018)

, 1 min read

The majority of people dying are 80 years old or older. A heart-disease drug can partially reverse type 1 diabetes. We can at least partially reverse age-related immune-system decline using drugs. Senescent cells are old cells that refuse to die; they are behind several age-related diseases. We…

Science and Technology links (July 15th, 2018)

, 4 min read

One of the problems that occur with aging is that your immune system becomes less efficient, less able to learn. If we could reverse this effect, it would be akin to rejuvenation. And it seems to be around the corner according to a new article published by Science: The objective of this phase 2a…

Are fungi making us sick?

, 3 min read

Fungi are everywhere. Yeasts, molds, mushrooms. We eat them. They live on our skin. But are they making us sick? That’s a theory strongly held by Martin Laurence. Martin created his own lab (Shipshaw labs) and even wrote a book on the topic. He reports that psoriasis and inflammatory bowel…

Science and Technology links (July 6th, 2018)

, 1 min read

In the United Kingdom, only a tiny minority of high school female students take computer science (0.4% in 2017). Physics is ten times more popular. Russians once drilled a 12-km deep hole. Apparently, it gets very hot as you dig deeper. Deep neural networks can detect myocardial infarction in…