From 3722da3b4e8233138f9df16ffc9cb5cb120950d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Apr 2017 11:48:00 +1000 Subject: [PATCH 1/5] Cleanup: quiet harmless but annoying overflow Caused asan to print warnings generating RNA --- source/blender/makesrna/intern/makesrna.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 4552c773097..9d68c05dda0 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -507,7 +507,7 @@ static void rna_float_print(FILE *f, float num) { if (num == -FLT_MAX) fprintf(f, "-FLT_MAX"); else if (num == FLT_MAX) fprintf(f, "FLT_MAX"); - else if ((int64_t)num == num) fprintf(f, "%.1ff", num); + else if ((ABS(num) < INT64_MAX) && ((int64_t)num == num)) fprintf(f, "%.1ff", num); else fprintf(f, "%.10ff", num); } From 1e6038a426b992bf991040eac18ae7d83ae6a8bb Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Tue, 11 Apr 2017 02:36:08 -0400 Subject: [PATCH 2/5] Cycles: Implement automatic global size for CUDA split kernel Not sure this is the best way to do things for CUDA but its much better than being unimplemented. --- intern/cycles/device/device_cuda.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 4c1a49878f5..ef283c9d455 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -1613,10 +1613,23 @@ int2 CUDASplitKernel::split_kernel_local_size() return make_int2(32, 1); } -int2 CUDASplitKernel::split_kernel_global_size(device_memory& /*kg*/, device_memory& /*data*/, DeviceTask * /*task*/) +int2 CUDASplitKernel::split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask * /*task*/) { - /* TODO(mai): implement something here to detect ideal work size */ - return make_int2(256, 256); + size_t free; + size_t total; + + device->cuda_push_context(); + cuda_assert(cuMemGetInfo(&free, &total)); + device->cuda_pop_context(); + + VLOG(1) << "Maximum device allocation size: " + << string_human_readable_number(free) << " bytes. (" + << string_human_readable_size(free) << ")."; + + size_t num_elements = max_elements_for_max_buffer_size(kg, data, free / 2); + int2 global_size = make_int2(round_down((int)sqrt(num_elements), 32), (int)sqrt(num_elements)); + VLOG(1) << "Global size: " << global_size << "."; + return global_size; } bool device_cuda_init(void) From d097c72f81a7a61ac5b96ca691114ac2765823d0 Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Tue, 11 Apr 2017 03:02:43 -0400 Subject: [PATCH 3/5] Cycles: Only calculate global size of split kernel once to avoid changes Global size depends on memory usage which might change during rendering. Havent seen it happen but seems possible that this could cause the global size to be different than what was used for allocating buffers. --- intern/cycles/device/device_split_kernel.cpp | 27 ++++++++++---------- intern/cycles/device/device_split_kernel.h | 3 +++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/intern/cycles/device/device_split_kernel.cpp b/intern/cycles/device/device_split_kernel.cpp index fa641161c05..981ec74fe56 100644 --- a/intern/cycles/device/device_split_kernel.cpp +++ b/intern/cycles/device/device_split_kernel.cpp @@ -128,26 +128,27 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task, local_size[1] = lsize[1]; } - /* Set gloabl size */ - size_t global_size[2]; - { - int2 gsize = split_kernel_global_size(kgbuffer, kernel_data, task); - - /* Make sure that set work size is a multiple of local - * work size dimensions. - */ - global_size[0] = round_up(gsize[0], local_size[0]); - global_size[1] = round_up(gsize[1], local_size[1]); - } - /* Number of elements in the global state buffer */ int num_global_elements = global_size[0] * global_size[1]; - assert(num_global_elements % WORK_POOL_SIZE == 0); /* Allocate all required global memory once. */ if(first_tile) { first_tile = false; + /* Set gloabl size */ + { + int2 gsize = split_kernel_global_size(kgbuffer, kernel_data, task); + + /* Make sure that set work size is a multiple of local + * work size dimensions. + */ + global_size[0] = round_up(gsize[0], local_size[0]); + global_size[1] = round_up(gsize[1], local_size[1]); + } + + num_global_elements = global_size[0] * global_size[1]; + assert(num_global_elements % WORK_POOL_SIZE == 0); + /* Calculate max groups */ /* Denotes the maximum work groups possible w.r.t. current requested tile size. */ diff --git a/intern/cycles/device/device_split_kernel.h b/intern/cycles/device/device_split_kernel.h index 15a94953a11..55548122c0c 100644 --- a/intern/cycles/device/device_split_kernel.h +++ b/intern/cycles/device/device_split_kernel.h @@ -95,6 +95,9 @@ private: /* Marked True in constructor and marked false at the end of path_trace(). */ bool first_tile; + /* Cached global size */ + size_t global_size[2]; + public: explicit DeviceSplitKernel(Device* device); virtual ~DeviceSplitKernel(); From 31bdb31ecf541960f7edcf564107ef8f75b0ee9b Mon Sep 17 00:00:00 2001 From: raa Date: Tue, 11 Apr 2017 13:25:46 +0300 Subject: [PATCH 4/5] Fix: width of UILayout.prop_enum() buttons --- source/blender/editors/interface/interface_layout.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 9b6547cf8a1..30a2094fee7 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1274,7 +1274,8 @@ static void ui_item_rna_size( if (!w) { if (type == PROP_ENUM && icon_only) { w = ui_text_icon_width(layout, "", ICON_BLANK1, 0); - w += 0.6f * UI_UNIT_X; + if (index != RNA_ENUM_VALUE) + w += 0.6f * UI_UNIT_X; } else { w = ui_text_icon_width(layout, name, icon, 0); From 0ebe08af34243631c7826c465cd8429bb20bd98d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 12 Apr 2017 14:21:59 +1000 Subject: [PATCH 5/5] Docs: minor improvement to code example --- source/blender/makesdna/DNA_meshdata_types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 621807d111c..3676066a399 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -164,8 +164,8 @@ typedef struct MLoop { * MEdge *ed = &medge[mloop[lt->tri[j]].e]; * unsigned int tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v}; * - * if (ELEM(ed->v1, tri_edge[0], tri_edge[1]) && - * ELEM(ed->v2, tri_edge[0], tri_edge[1])) + * if (((ed->v1 == tri_edge[0]) && (ed->v1 == tri_edge[1])) || + * ((ed->v1 == tri_edge[1]) && (ed->v1 == tri_edge[0]))) * { * printf("real edge found %u %u\n", tri_edge[0], tri_edge[1]); * }