HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
rikusalminen
threedee-simd
C2012–2018
rikusalminen / threedee-simd

threedee-simd

3d math with C and SIMD intrinsics

2Distinct people
9Mentions
0Explicit recommenders
45GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

3d math with C and SIMD intrinsics

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 5:04:57 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year9 dated mentions

Observed mentions: 2012-09-14 22:00:34 UTC to 2018-06-11 08:10:34 UTC.

01232012-01-01 00:00:00 UTC to 2013-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20122013-01-01 00:00:00 UTC to 2014-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2014-01-01 00:00:00 UTC to 2015-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2018

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20122012-01-01 00:00:00 UTC2013-01-01 00:00:00 UTC101
20132013-01-01 00:00:00 UTC2014-01-01 00:00:00 UTC202
20142014-01-01 00:00:00 UTC2015-01-01 00:00:00 UTC303
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC000
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC202
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC000
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC101

What Hacker News says

9 sources
What the C++ (and C) stadards could use is a native type for SIMD vectors. In other words, standardize the GCC vector extensions [0] or some variant thereof. Just adding a new header-only library for vector arithmetic isn't something that needs to be in the language standard (library), there are lots of options for that already (such as glm[1]). I've been using vector extensions for my 3d graphics and physics stuff for years now and it works great. There are some pain points, but it already covers most of what I need. As a bonus, it can be used in plain C and you get all the usual math operators (+, -, /, etc) for free. There are minor incompatibilities between GCC and Clang, but nothing a few #ifdefs won't solve. Here's a quick introduction in a few lines of code: typedef float vec4f __attribute__((vector_size(16))); vec4f a = {
Read the rest
1, 2, 3, 4 }, b = { 5, 6, 7, 8 }; vec4f c = a + b; vec4f d = (a + b) * c; // with --ffast-math, you will get fused multiply-and-add (MAD) In my projects, I've always put together an ad-hoc collection of arithmetic routines I need (e.g. dot, cross, matrix product, inverse, etc). A proper, well tested library of basic math operations for SIMD vectors would be very useful but I haven't got the time it takes. If anyone is interested, some of my math routines are bundled in this github repo [2]. It's incomplete, undocumented, not well tested and there are known issues I haven't gotten around to (e.g. quaternion products give wrong results). If anyone thinks this is useful and is interested in contributing/collaborating, leave a comment. [0] https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html [1] https://glm.g-truc.net/0.9.9/index.html [2] https://github.com/rikusalminen/threedee-simd
In 2D or not 2D (in the C++ Standard) – that is the question
> And wrappers exists in the C++ ecosystem, C programmers are stuck to intrinsics. If you can accept working with GNU extensions that are available in recent-ish GCC and Clang (but not MSVC, not sure about Intel ICC), there are pretty nice vector extensions [0]. With them you can get standard binary operators working for arithmetic (+,-,*,/ etc) and shuffling with __builtin_shuffle. These are CPU independent, the same code compiles neatly to ARM NEON as well as x86 SSE+AVX+FMA. All you need is a typedef with an __attribute__. The vector extension functions don't cover the whole instruction sets but the vector types are compatible with _mm128 and NEON native formats so you can resort to intrinsics when necessary. However, for a lot of SIMD tasks I encounter, just basic arithmetic + shuffles is more than 80% of what I need. If you want to s
Read the rest
ee some examples, take a look at my collection of 3d graphics and physics related SIMD routines [1]. (note: this project could use some help, let me know if you're interested in doing something with it or porting some of the hand optimized routines to more used math libs like glm) [0] https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html#Ve... [1] https://github.com/rikusalminen/threedee-simd
In SSE: mind the gap
This made me think of clang/gcc's vector extensions [1], which, together with __builtin_shuffle can be used to get some real "ok" cross-platform (SSE/NEON/...) SIMD code going on. An example of this in usage is [2]. That said you're right, usually the best performance can only be obtained by using really specific instructions. But in my experience, a decent performance increase can be obtained by using the generic vector extensions. Moreover, if you can use the vector extensions for a large part of the code, that means you have to write a lot less platform-specific stuff. I.e.: you increase portability anyway, since now you only have to rewrite 5 out of 20 functions instead of 20/20. Even better, they allow one to write v3 = v1 + v2 instead of v3 = _mm_add_ps(v1,v2). The first one being clearer, more portable (will generate appropriate ad
Read the rest
dps or equivalent NEON, ...) and plain nicer to read. Your pcmpeqd example is a good example of an optimizer flaw. In my opinion this is orthogonal to whether or not to expose a specific or generic API. The compiler should've use the most efficient instruction for that simple idiom, period (without you telling it to use pcmpeqd). If we continue your line of reasoning, we're back to assembly for everything. [1]: https://vec.io/posts/gcc-and-clang-vector-extensions (The vector extensions allow +,-,*,/,<,>,==,!= to be naturally used for SIMD types) [2]: https://github.com/rikusalminen/threedee-simd
In .NET JIT and SIMD are getting married
No, pass by value is a lot faster if the values being passed can be passed in registers, which is the case with SIMD vector values and inline functions. Passing by pointer adds restrictions to what the compiler can optimize and in the worst case you actually end up pushing values to the stack just to read them back to registers in the called function. I recently spent a good deal of time looking at assembly code emitted by compilers when doing SIMD code with C and intrinsics. On GCC and Clang pass by value and force_inline functions gave the best results (at least until link time optimization becomes more mainstream). This was even the case with 4x4 matrix structs, not just SIMD vectors. The speed is not in getting individual functions to work fast, but to let the compiler inline and combine several function calls together and keeping liv
Read the rest
e values in registers from one function to another. Here's my SIMD math lib: https://github.com/rikusalminen/threedee-simd
In Practical Cross Platform SIMD Math
Shuffles are what makes SIMD go. It's trivial to make simple repeated math ops done in parallel instead of 4 (SIMD vector width) times sequentially, but shuffling vectors cleverly is where you can get big performance wins. Basic example, doing addition of 4 values in 2 ALU operations: vec4 sum(vec4 v) // return v.x+v.y+v.z+v.w repeated 4 times { vec4 temp = v + v.yxzw; return temp + temp.zwxy; // did I get this right? } Practical examples: https://github.com/rikusalminen/threedee-simd (work in progress) Requires this: http://gruntthepeon.free.fr/ssemath/
In The most useful GCC options and extensions

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.