forked from bartvdbraak/blender
Fix T53830: Cycles OpenCL debug assert on macOS,
This was probably harmless besides some unnecessary memory usage due to aligning allocations too much.
This commit is contained in:
parent
889321e22b
commit
0fe41009f0
@ -286,7 +286,7 @@ public:
|
||||
Stats &stats;
|
||||
|
||||
/* memory alignment */
|
||||
virtual int mem_address_alignment() { return 16; }
|
||||
virtual int mem_address_alignment() { return MIN_ALIGNMENT_CPU_DATA_TYPES; }
|
||||
|
||||
/* constant memory */
|
||||
virtual void const_copy_to(const char *name, void *host, size_t size) = 0;
|
||||
|
@ -50,8 +50,7 @@ void *device_memory::host_alloc(size_t size)
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t alignment = device->mem_address_alignment();
|
||||
void *ptr = util_aligned_malloc(size, alignment);
|
||||
void *ptr = util_aligned_malloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES);
|
||||
|
||||
if(ptr) {
|
||||
util_guarded_mem_alloc(size);
|
||||
|
@ -1137,14 +1137,14 @@ bool OpenCLInfo::get_driver_version(cl_device_id device_id,
|
||||
|
||||
int OpenCLInfo::mem_address_alignment(cl_device_id device_id)
|
||||
{
|
||||
int base_align_bits;
|
||||
int base_align_bytes;
|
||||
if(clGetDeviceInfo(device_id,
|
||||
CL_DEVICE_MEM_BASE_ADDR_ALIGN,
|
||||
CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE,
|
||||
sizeof(int),
|
||||
&base_align_bits,
|
||||
&base_align_bytes,
|
||||
NULL) == CL_SUCCESS)
|
||||
{
|
||||
return base_align_bits/8;
|
||||
return base_align_bytes;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Minimum alignment needed by all CPU native data types (SSE, AVX). */
|
||||
#define MIN_ALIGNMENT_CPU_DATA_TYPES 16
|
||||
|
||||
/* Allocate block of size bytes at least aligned to a given value. */
|
||||
void *util_aligned_malloc(size_t size, int alignment);
|
||||
|
||||
|
@ -86,9 +86,9 @@ public:
|
||||
* this was actually showing up in profiles quite significantly. it
|
||||
* also does not run any constructors/destructors
|
||||
* - if this is used, we are not tempted to use inefficient operations
|
||||
* - aligned allocation for SSE data types */
|
||||
* - aligned allocation for CPU native data types */
|
||||
|
||||
template<typename T, size_t alignment = 16>
|
||||
template<typename T, size_t alignment = MIN_ALIGNMENT_CPU_DATA_TYPES>
|
||||
class array
|
||||
{
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user