Cleanup and refactor our atomic library.

This commit:
* Removes most of all dirty internal details from public atomi_ops.h file, and move them into /intern private subdir.
* Removes unused 'architectures' (__apple__ and jemalloc).
* Split each implementation into its own file.
* Makes use of C99's limits.h system header to determine pointer and int size, instead of using fix hardcoded list of architectures.
* Introduces new 'faked' atomics ops for floats.

Note that we may add a lot more real and 'faked' atomic operations over integers and floats
(multiplication, division, bitshift, bitwise booleans, etc.), as needs arise.

Reviewers: sergey, campbellbarton

Differential Revision: https://developer.blender.org/D1982
This commit is contained in:
Bastien Montagne
2016-05-09 17:03:08 +02:00
parent 299a25cb35
commit ba3ae9ea27
6 changed files with 590 additions and 464 deletions

View File

@@ -979,16 +979,7 @@ static void pbvh_update_normals_accum_task_cb(void *userdata, const int n)
* Not exact equivalent though, since atomicity is only ensured for one component
* of the vector at a time, but here it shall not make any sensible difference. */
for (int k = 3; k--; ) {
/* Atomic float addition.
* Note that since collision are unlikely, loop will nearly always run once. */
float oldval, newval;
uint32_t prevval;
do {
oldval = vnors[v][k];
newval = oldval + fn[k];
prevval = atomic_cas_uint32(
(uint32_t *)&vnors[v][k], *(uint32_t *)(&oldval), *(uint32_t *)(&newval));
} while (UNLIKELY(prevval != *(uint32_t *)(&oldval)));
atomic_add_fl(&vnors[v][k], fn[k]);
}
}
}