Commit Graph

293 Commits

Author SHA1 Message Date
Brecht Van Lommel
4f622c9a08 Fix Windows build after recent guardedalloc changes 2020-05-20 00:32:17 +02:00
Brecht Van Lommel
183ba284f2 Cleanup: make guarded memory allocation always thread safe
Previously this would be enabled when threads were used, but threads are now
basically always in use so there is no point. Further, this is only needed for
guarded allocation with --debug-memory which is not performance critical.
2020-05-20 01:03:05 +02:00
Brecht Van Lommel
120e9924c1 Cleanup: remove legacy mmap memory allocation for 32 bit
This helped to go beyond the 4GB limit, but is no longer relevant for 64 bit.
2020-05-20 00:57:41 +02:00
Jacques Lucke
975c45df9a Cleanup: don't use deprecated exception specifications
Usage of exception specifications is discouraged by the C++ core guidelines.
2020-05-14 11:24:50 +02:00
Dalai Felinto
2d1cce8331 Cleanup: make format after SortedIncludes change 2020-03-19 09:33:58 +01:00
James Fulop
6ab359e525 Fix potential crash in guarded alloc stats, when there are no allocations
This was found with static analysis warnings in Visual Studio 2019.

Differential Revision: https://developer.blender.org/D6564
2020-01-31 13:01:07 +01:00
c76a8f65b7 Memory: add OBJECT_GUARDED_SAFE_DELETE like MEM_SAFE_FREE 2020-01-27 12:22:01 +01:00
1107af1abb Fix OBJECT_GUARDED_FREE compiler error when type is in namespace 2020-01-27 12:22:01 +01:00
Jacques Lucke
9c9ea37770 Fix: Use a minimal alignment of 8 in MEM_lockfree_mallocN_aligned
`posix_memalign` requires the `alignment` to be at least `sizeof(void *)`.
Previously, `MEM_mallocN_aligned` would simply return `NULL` if a too small
`alignment` was used. This was an OS specific issue.

The solution is to use a minimal alignment of `8` for all aligned allocations.
The unit tests have been extended to test more possible alignments (some
of which were broken before).

Reviewers: brecht

Differential Revision: https://developer.blender.org/D6660
2020-01-23 14:21:48 +01:00
64cd9a079b Fix T70952: EXR files bigger than 2GB don't open on Windows 2019-11-06 17:16:46 +01:00
Campbell Barton
312075e688 CMake: add missing headers, use space before comments 2019-10-29 01:33:44 +11:00
Stefan Werner
ca76ecfa0e Cleanup: clang-format 2019-09-14 09:26:51 +02:00
Stefan Werner
c80564ef9f macOS: Enabled posix_memalign() like on other Unix platforms. 2019-09-13 22:49:26 +02:00
Jacques Lucke
f2cab8267f Memory: Fix guarded aligned malloc with small alignment
When calling `MEM_guarded_mallocN_aligned` with an alignment of 4,
a pointer that was returned that is 4 byte but not 8 byte aligned.
When freeing this pointer, `MEM_guarded_freeN` thinks that it is an
illegal pointer, because it asserts that `((intptr_t)memh) & 0x7 == 0`.

The fix is to always use at least 8 byte alignment.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5529
2019-08-20 09:45:47 +02:00
Campbell Barton
177a0ca131 Cleanup: comments (long lines) in various intern/ libs 2019-05-01 21:00:56 +10:00
Campbell Barton
a54bdd76cb ClangFormat: format '#if 0' code
Previous cleanups didn't account for space after '#'.
2019-04-17 08:52:59 +02:00
Campbell Barton
108045faa0 ClangFormat: format '#if 0' code in intern/ 2019-04-17 08:17:13 +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
47adab4f99 CMake: prepare for BLENDER_SORTED_LIBS removal
No functional change, this adds LIB definition and args to cmake files.
Without this it's difficult to migrate away from 'BLENDER_SORTED_LIBS'
since there are many platforms/configurations that could break when
changing linking order.

Manually add and enable WITHOUT_SORTED_LIBS to try building
without sorted libs (currently fails since all variables are empty).
This check will eventually be removed.

See T46725.
2019-04-14 15:37: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
3316853323 Cleanup: conform headers to have license first
Also remove doxy comments for licenses and add missing GPL header.
2019-02-18 08:22:11 +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
ab5e69e660 Cleanup: remove contributors for CMake files
Following removal from C source code.

See: 8c68ed6df16d8893
2019-02-05 09:10:32 +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
Campbell Barton
4d29312c66 Cleanup: trailing space guardedalloc & memutil 2019-01-24 16:22:44 +11:00
Campbell Barton
302970b7a5 MSVC: remove compiler __func__ define
No longer needed and exposes a bug in clang-format see: D4185
2019-01-11 09:22:21 +11:00
d05b9e0a2e Fix build with older CMake versions that we still need to support. 2018-10-03 12:55:43 +02:00
d2da3af073 Fix T54287: memory not freed after rendering on Linux.
With new jemalloc versions memory allocated by threads that then become
inactive is not longer automatically freed. Instead we have to enable a
background thread to do it.

Some testing is needed to find out of this is sufficient, because the
background thread only runs periodically.
2018-10-03 12:09:31 +02:00
Campbell Barton
103a31f712 Fix incorrect size in aligned lockfree realloc
Thanks to @alikendarfen for finding.
2018-05-23 07:24:57 +02:00
Campbell Barton
28c20fc393 Memory allocator: use lockfree calls internally
Was already used in some areas.
2018-05-22 08:45:47 +02:00
Sergey Sharybin
a5bb918392 Memory allocator: Clarify consistency check function
Also make it to return truth when everything is good and
false otherwise.
2018-03-20 16:51:33 +01:00
a6700362c7 Memory: add MEM_malloc_arrayN() function to protect against overflow.
Differential Revision: https://developer.blender.org/D3002
2018-01-17 19:59:47 +01:00
Campbell Barton
28d2148b09 Haiku OS Support
D2860 by @miqlas

Even though Haiku is a niche OS, only minor changes are needed.
2017-11-30 18:05:21 +11:00
Campbell Barton
5a1954a5cb Drop platform support for Solaris & AIX
These platforms didn't see maintenance in years.
This commit just removes ifdef's & cmake check.
2017-09-29 19:16:34 +10: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
Sergey Sharybin
8bf108dd48 Guarded allocator: Fix type in macro definition
The crash did not happen yet because we always had proper vmemh defined in
the parent scope.

Patch by Ivan Ivanov (aka obiwanus), thanks!

Differential Revision: https://developer.blender.org/D2715
2017-06-17 16:13:30 +02:00
Aaron Carlisle
9f044cb422 Remove MinGW support
The Issue
=======

For a long time now MinGW has been unsupported and unmaintained and at this point,
it looks like something that we should just leave behind and move on.


Why Remove
==========

One of the big motivations for MinGW back in the day is that it was free compared to MSVC which was licensed based.
However, now that this is no longer true we have basically stopped updating the need CMake files.
Along with the CMake files, there are several patches to the extern libs needed to make this work.  For example, see:
https://developer.blender.org/diffusion/B/browse/master/extern/carve/patches/mingw_w64.patch

If we wanted to keep MinGW then we would need to make more custom patches to the external libs and
this is not something our platform maintainers are willing to do.

For example, here is the patches needed to build python: https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-python3

Fixes T51301

Differential Revision: https://developer.blender.org/D2648
2017-05-27 15:34:55 -04:00
Sergey Sharybin
4ee08e9533 Atomics: Make naming more obvious about which value is being returned 2016-11-15 12:16:26 +01:00
Campbell Barton
8343518272 Cleanup: comment blocks 2016-07-15 02:39:45 +10:00
Sergey Sharybin
5d99cde822 Remove SCons building system
While SCons building system was serving us really good for ages it's no longer
having much attention by the developers and started to become quite a difficult
task to maintain.

What's even worse -- there started to be quite serious divergence between SCons
and CMake which was only accumulating over the releases now. The fact that none
of the active developers are really using SCons and that our main studio is also
using CMake spotting bugs in the SCons builds became quite a difficult task and
we aren't always spotting them in time.

Meanwhile CMake became really mature building system which is available on every
platform we support and arguably it's also easier and more robust to use.

This commit includes:

- Removal of actual SCons building system
- Removal of SCons git submodule
- Removal of documentation which is stored in the sources and covers SCons
- Tweaks to the buildbot master to stop using SCons submodule
  (this change requires deploying to the server)
- Tweaks to the install dependencies script to skip installing or mentioning
  SCons building system
- Tweaks to various helper scripts to avoid mention of SCons folders/files
  as well

Reviewers: mont29, dingto, dfelinto, lukastoenne, lukasstockner97, brecht, Severin, merwin, aligorith, psy-fi, campbellbarton, juicyfruit

Reviewed By: campbellbarton, juicyfruit

Differential Revision: https://developer.blender.org/D1680
2016-01-04 14:20:48 +05:00
Campbell Barton
8d752141ce Support for platforms /wo malloc_usable_size
Was only used for stats, netbsd doesn't define this function.
2015-06-21 12:33:55 +10:00
Sergey Sharybin
6298632bfa Guardedalloc: Don't use aligned blocks to calculate memory sloppyness
Aligned memory is allocated with memalign() and malloc_usable_size() can't be
used to measure this block.
2015-04-20 19:23:25 +05:00
Campbell Barton
17d96ca2aa GuardedAlloc: safer MEM_SAFE_FREE
only instantiate the argument once,
so MEM_SAFE_FREE(array[i++]), won't cause incorrect behavior.
2015-03-12 23:49:15 +11:00
Sergey Sharybin
9fc2c37328 Guardedalloc: Reset peak memory should set peak to currently allocated memory
Otherwise statistics could be really funny looking.
2015-02-19 13:14:06 +05:00
Sergey Sharybin
6c5f63b476 Guardedalloc: Add extra logging and checks in MEM_freeN()
We don't like when NULL is send to MEM_freeN(), but there was some
differences between lockfree and guarded allocators:

- Lockfree would have silently crash, in both release and debug modes
- Guarded allocator would have printed error message, abort in debug
  but keep working in release build.

This commit makes lockfree allocator behavior to match guarded one.
2015-02-19 01:58:49 +05:00
Dan Horák
c86c9297dc Fix inconsistent types in guardealloc
This basically fixes mix of size_t and uintptr_t usages which might be different size.
2014-10-14 16:11:20 +02:00
Sergey Sharybin
f2280661cb Enable atomic peak memory detection
This gives more precise information about memory usage which might be real handy
when doing memory optimization.

It works good here for as long as i can tell but if for some reason you'll be
experiencing some weird slowdown please let me know.
2014-10-10 01:55:57 +06:00
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
faf4f29cc0 Guardedalloc: Implement atomic peak memory update
Updating maximum requires a bit of a cycle which usually does 1 iteration only,
sometimes needs a bit more but seems there's no speed regressions.

For now the code is commented out. This way it's easier for others to verify
there's no speed regressions.

Reviewers: campbellbarton

Differential Revision: https://developer.blender.org/D626
2014-09-26 00:40:53 +06:00