Commit Graph

48 Commits

Author SHA1 Message Date
Dalai Felinto 2d1cce8331 Cleanup: `make format` after SortedIncludes change 2020-03-19 09:33:58 +01:00
Campbell Barton a91717d2ad Cleanup: comments (long lines) in atomic 2019-05-01 20:34:12 +10:00
Campbell Barton 3fe6eebf20 Cleanup: line wrapping caused by comments 2019-04-17 18:50:53 +02:00
Campbell Barton e12c08e8d1 ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.

For details on usage and instructions for migrating branches
without conflicts, see:

https://wiki.blender.org/wiki/Tools/ClangFormat
2019-04-17 06:21:24 +02:00
Campbell Barton de13d0a80c doxygen: add newline after \file
While \file doesn't need an argument, it can't have another doxy
command after it.
2019-02-18 08:22:12 +11:00
Campbell Barton eef4077f18 Cleanup: remove redundant doxygen \file argument
Move \ingroup onto same line to be more compact and
make it clear the file is in the group.
2019-02-06 15:45:22 +11:00
Campbell Barton 4ef09cf937 Cleanup: remove author/date info from doxy headers 2019-02-02 11:58:24 +11:00
Campbell Barton 65ec7ec524 Cleanup: remove redundant, invalid info from headers
BF-admins agree to remove header information that isn't useful,
to reduce noise.

- BEGIN/END license blocks

  Developers should add non license comments as separate comment blocks.
  No need for separator text.

- Contributors

  This is often invalid, outdated or misleading
  especially when splitting files.

  It's more useful to git-blame to find out who has developed the code.

See P901 for script to perform these edits.
2019-02-02 01:36:28 +11:00
Sergey Sharybin b00819bcca Atomic: Avoid conflicts with definitions in other areas
While atomics library was trying to use "user-space" defined
LIKELY() and UNLIKELY(), this is not always true that user
code was checking for those macro coming from an unrelated
area.
2018-11-29 09:33:50 +01:00
Ray Molenkamp 81060ff6b2 Windows: Add support for building with clang.
This commit contains the minimum to make clang build/work with blender, asan and ninja build support is forthcoming

Things to note:

1) Builds and runs, and is able to pass all tests (except for the freestyle_stroke_material.blend test which was broken at that time for all platforms by the looks of it)

2) It's slightly faster than msvc when using cycles. (time in seconds, on an i7-3370)

victor_cpu
	msvc:3099.51
	clang:2796.43

pavillon_barcelona_cpu
	msvc:1872.05
	clang:1827.72

koro_cpu
	msvc:1097.58
	clang:1006.51

fishy_cat_cpu
	msvc:815.37
	clang:722.2

classroom_cpu
	msvc:1705.39
	clang:1575.43

bmw27_cpu
	msvc:552.38
	clang:561.53

barbershop_interior_cpu
	msvc:2134.93
	clang:1922.33

3) clang on windows uses a drop in replacement for the Microsoft cl.exe (takes some of the Microsoft parameters, but not all, and takes some of the clang parameters but not all) and uses ms headers + libraries + linker, so you still need visual studio installed and will use our existing vc14 svn libs.

4) X64 only currently, X86 builds but crashes on startup.

5) Tested with llvm/clang 6.0.0

6) Requires visual studio integration, available at https://github.com/LazyDodo/llvm-vs2017-integration

7) The Microsoft compiler spawns a few copies of cl in parallel to get faster build times, clang doesn't, so the build time is 3-4x slower than with msvc.

8) No openmp support yet. Have not looked at this much, the binary distribution of clang doesn't seem to include it on windows.

9) No ASAN support yet, some of the sanitizers can be made to work, but it was decided to leave support out of this commit.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D3304
2018-05-28 14:34:47 -06:00
Bastien Montagne cf6e8edda5 atomic_ops: add `atomic_cas_float` helper. 2017-11-23 21:17:16 +01:00
Bastien Montagne ff9eab7926 atomic_ops: Copy/adapt static assert macro from BLI_utildefines, and use it.
Checking for type sizes is much nicer with a static assert!
2017-11-23 20:25:55 +01:00
Bastien Montagne e704d8a616 Moar attempt to fix bloody MSVC intrinsic mess... 2017-11-23 16:58:20 +01:00
Bastien Montagne df06f1c816 Attempt to fix bloody MSVC atomic intrinsic mess... 2017-11-23 16:53:03 +01:00
Bastien Montagne 580b34e52b atomic_ops: add char versions of uint8_t atomic primitives. 2017-11-23 16:24:34 +01:00
Bastien Montagne 105b95835f atomic_ops: add signed versions of primitives.
Reason is motsly that dealing with type conversion in calling code is
not great, makes it less readable, and can generate hidden bugs in case
original type changes and atomic primitive calls are not updated
accordingly...
2017-11-23 16:24:33 +01:00
Bastien Montagne 1d8aebaa09 Add an 'atomic cas' wrapper for pointers.
Avoids having to repeat obfuscating castings everywhere...
2017-09-25 10:40:50 +02:00
Sergey Sharybin f4b3678646 Atomics: Use system headers directly, without bad level dependency to BLI
This will make it easier to re-use library as-is in other projects,
such as Cycles standalone repo for example.
2017-08-28 11:06:15 +02:00
Mai Lavelle 2540741dee Fix implementation of atomic update max and move to a central location
While unlikely to have had any serious effects because of limited use, the
previous implementation was not actually atomic due to a data race and
incorrectly coded CAS loop. We also had duplicates of this code in a few
places, it's now been moved to a single location with all other atomic
operations.
2017-08-23 06:54:25 -04:00
Campbell Barton 5c963128ea Cleanup: remove check for old GCC&PPC 2017-07-27 07:29:16 +10:00
Sergey Sharybin 351c9239ed Cleanup: Use explicit unsigned int in atomics 2017-03-01 12:01:19 +01:00
Sergey Sharybin a284d04093 Atomics: Add some extra utility functions
Also fixed semantic of fetch-and-add in assembler implementation,
it seemed to not match the naming.
2016-11-15 13:41:08 +01:00
Sergey Sharybin 4ee08e9533 Atomics: Make naming more obvious about which value is being returned 2016-11-15 12:16:26 +01:00
Sergey Sharybin 682bcb2995 Atomics: Add 32 bit version of fetch and AND/OR 2016-11-08 17:12:04 +01:00
Campbell Barton 307250723b Fix building on NetBSD 2016-07-19 22:04:14 +10:00
Benoit Bolsee fa9bb2ffe9 Atomic ops: Fix atomic_add_uint32 and atomic_sub_uint32 in Windows
The assembler version in Windows used to return the previous value
    of the variable while all the other versions return the new value.
    This is now fixed for consistency.
    Note: this bug had no effect on blender because no part of the code
    use the return value of these functions, but the future BGE DeckLink
    module makes use of it to implement reference counter.
2016-06-11 22:15:25 +02:00
Bastien Montagne 75a96f8325 Atomic ops: add 'fetch_and_add_uint32' op.
Needed for next commit.
2016-05-16 15:56:39 +02:00
Campbell Barton 119230b565 Cleanup: header, style 2016-05-10 03:03:34 +10:00
Bastien Montagne ba3ae9ea27 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
2016-05-09 17:03:08 +02:00
Sergey Sharybin dc5e02c42c Atomics: Add atomic_fetch_and_or_uint8() function
Hopefully it compiles on all platforms still..
2016-05-09 11:45:43 +02:00
Sergey Sharybin c1ca667d4a Fix compilation error on Armel architecture
__GCC_HAVE_SYNC_COMPARE_AND_SWAP_n are not defined on this architecture
for some reason, however those functions are available.

Adding a workaround for newly used __sync_fetch_and_and() function.
2016-05-02 09:55:08 +02:00
Sergey Sharybin efefae62de Atomics: Use _InterlockedAnd8 direction for 342bit MSVC
That's what MSDN tells you to do and that's how to solve the compilation
error problem with it.
2016-01-27 14:16:02 +01:00
Bastien Montagne 7e9103b49c atomic_ops: add atomic_fetch_and_and_uint8 wrapper.
Needed by incomming changes in pbvh.c.

Note that we make it much simpler than for other primitives in this file - think
we could revise its content to make it simpler one day...
2016-01-27 12:26:00 +01:00
Bastien Montagne 53d12bbe04 atomic_ops: Fix MSVC versions of add/sub returning original value instead of result of operation.
Thanks to Brecht for tip about how to fix this!
2015-07-01 12:25:32 +02:00
Bastien Montagne 174d5cf627 atomic_ops: fix typo in func names (uint32 instead of uint64). 2015-07-01 12:25:31 +02:00
Sergey Sharybin 28b2977be9 Atomic operations: Add function declarations at the top of the header
No functional changes, just helps grasping what operations are actually
supported.
2015-05-20 11:57:17 +05:00
Sergey Sharybin 18d08ede22 Fixes for atomic operations when building with MSVC 2014-12-02 16:38:09 +05:00
Brecht Van Lommel 32f83a298c Fix build errors in atomic ops and warning in aligned malloc on OS X. 2014-09-25 23:59:38 +02:00
Sergey Sharybin 37f3843ab0 Atomics: Add CAS (compare-and-swap) functions 2014-09-26 00:33:04 +06:00
Matteo F. Vescovi c3f09c06cb Fix atomix operations on unofficial 64bit archs 2014-07-25 12:26:10 +06:00
Matteo F. Vescovi 4b2c826178 Fix compilation on unofficial 64bit archs 2014-06-02 16:27:09 +06:00
Sergey Sharybin abb7e9f09b Attempt to fix compilation error on Debian armel kernel 2013-12-12 17:33:36 +06:00
Brecht Van Lommel 4bcccc24c1 Fix OS X compile error after enabling strict build flags for this module. 2013-09-01 14:10:41 +00:00
Campbell Barton 20fdea918d code cleanup: confirm include guards to our convention 2013-08-19 14:40:16 +00:00
Sergey Sharybin cbfd2a8e62 Apparently sizeof(unsigned) is 4 bytes on both 32 and 64 bit platforms
For now assume sizeof(int) == 4 for all supported platforms, could be
changed in the future.

Added an assert to functions which depends on this this, so we'll
easily notice bad things happening.
2013-08-19 14:03:44 +00:00
Sergey Sharybin 499ccf731b Forgot this in previous commit
Solves compilation issues on Win and OSX

--
svn merge -r59180:59181 ^/branches/soc-2013-depsgraph_mt
2013-08-19 10:53:10 +00:00
Sergey Sharybin c0f8e15295 Speedup for guarded allocator
- Re-arrange locks, so no actual memory allocation
  (which is relatively slow) happens from inside
  the lock. operation system will take care of locks
  which might be needed there on it's own.

- Use spin lock instead of mutex, since it's just
  list operations happens from inside lock, no need
  in mutex here.

- Use atomic operations for memory in use and total
  used blocks counters.

This makes guarded allocator almost the same speed
as non-guarded one in files from Tube project.

There're still MemHead/MemTail overhead which might
be bad for CPU cache utilization
2013-08-19 10:51:40 +00:00
Sergey Sharybin efa836531e Commit atomic operations file
Not currently used, but needed for some further changes
2013-08-19 10:44:18 +00:00