2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
#include "device.h"
|
|
|
|
#include "device_intern.h"
|
|
|
|
#include "device_network.h"
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
#include "buffers.h"
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "util_foreach.h"
|
|
|
|
#include "util_list.h"
|
|
|
|
#include "util_map.h"
|
|
|
|
#include "util_time.h"
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class MultiDevice : public Device
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct SubDevice {
|
|
|
|
SubDevice(Device *device_)
|
|
|
|
: device(device_) {}
|
|
|
|
|
|
|
|
Device *device;
|
|
|
|
map<device_ptr, device_ptr> ptr_map;
|
|
|
|
};
|
|
|
|
|
|
|
|
list<SubDevice> devices;
|
|
|
|
device_ptr unique_ptr;
|
|
|
|
|
2012-11-05 08:04:57 +00:00
|
|
|
MultiDevice(DeviceInfo& info, Stats &stats, bool background_)
|
2013-12-07 01:29:53 +00:00
|
|
|
: Device(info, stats, background_), unique_ptr(1)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
Device *device;
|
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
foreach(DeviceInfo& subinfo, info.multi_devices) {
|
2012-11-05 08:04:57 +00:00
|
|
|
device = Device::create(subinfo, stats, background);
|
2011-04-27 11:58:34 +00:00
|
|
|
devices.push_back(SubDevice(device));
|
|
|
|
}
|
|
|
|
|
2013-12-07 01:29:53 +00:00
|
|
|
#ifdef WITH_NETWORK
|
2011-04-27 11:58:34 +00:00
|
|
|
/* try to add network devices */
|
|
|
|
ServerDiscovery discovery(true);
|
|
|
|
time_sleep(1.0);
|
|
|
|
|
2013-12-07 01:29:53 +00:00
|
|
|
vector<string> servers = discovery.get_server_list();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
foreach(string& server, servers) {
|
2013-12-07 01:29:53 +00:00
|
|
|
device = device_network_create(info, stats, server.c_str());
|
2011-04-27 11:58:34 +00:00
|
|
|
if(device)
|
|
|
|
devices.push_back(SubDevice(device));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
~MultiDevice()
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
|
|
|
delete sub.device;
|
|
|
|
}
|
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
const string& error_message()
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
if(sub.device->error_message() != "") {
|
|
|
|
if(error_msg == "")
|
|
|
|
error_msg = sub.device->error_message();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error_msg;
|
|
|
|
}
|
|
|
|
|
2011-12-12 22:51:35 +00:00
|
|
|
bool load_kernels(bool experimental)
|
2011-09-12 13:13:56 +00:00
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
2011-12-12 22:51:35 +00:00
|
|
|
if(!sub.device->load_kernels(experimental))
|
2011-09-12 13:13:56 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void mem_alloc(device_memory& mem, MemoryType type)
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
sub.device->mem_alloc(mem, type);
|
|
|
|
sub.ptr_map[unique_ptr] = mem.device_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = unique_ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mem_copy_to(device_memory& mem)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->mem_copy_to(mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
void mem_copy_from(device_memory& mem, int y, int w, int h, int elem)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
2012-01-09 16:58:01 +00:00
|
|
|
int i = 0, sub_h = h/devices.size();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
2012-01-09 16:58:01 +00:00
|
|
|
int sy = y + i*sub_h;
|
|
|
|
int sh = (i == (int)devices.size() - 1)? h - sub_h*i: sub_h;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
2012-01-09 16:58:01 +00:00
|
|
|
sub.device->mem_copy_from(mem, sy, w, sh, elem);
|
|
|
|
i++;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mem_zero(device_memory& mem)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->mem_zero(mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mem_free(device_memory& mem)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->mem_free(mem);
|
|
|
|
sub.ptr_map.erase(sub.ptr_map.find(tmp));
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void const_copy_to(const char *name, void *host, size_t size)
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
|
|
|
sub.device->const_copy_to(name, host, size);
|
|
|
|
}
|
|
|
|
|
2014-03-07 22:16:09 +00:00
|
|
|
void tex_alloc(const char *name, device_memory& mem, InterpolationType interpolation, bool periodic)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
sub.device->tex_alloc(name, mem, interpolation, periodic);
|
|
|
|
sub.ptr_map[unique_ptr] = mem.device_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = unique_ptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
void tex_free(device_memory& mem)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->tex_free(mem);
|
|
|
|
sub.ptr_map.erase(sub.ptr_map.find(tmp));
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pixels_alloc(device_memory& mem)
|
|
|
|
{
|
2011-09-12 13:13:56 +00:00
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = 0;
|
|
|
|
sub.device->pixels_alloc(mem);
|
|
|
|
sub.ptr_map[unique_ptr] = mem.device_pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = unique_ptr++;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pixels_free(device_memory& mem)
|
|
|
|
{
|
2011-09-12 13:13:56 +00:00
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->pixels_free(mem);
|
|
|
|
sub.ptr_map.erase(sub.ptr_map.find(tmp));
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = 0;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void pixels_copy_from(device_memory& mem, int y, int w, int h)
|
|
|
|
{
|
|
|
|
device_ptr tmp = mem.device_pointer;
|
|
|
|
int i = 0, sub_h = h/devices.size();
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
int sy = y + i*sub_h;
|
|
|
|
int sh = (i == (int)devices.size() - 1)? h - sub_h*i: sub_h;
|
|
|
|
|
|
|
|
mem.device_pointer = sub.ptr_map[tmp];
|
|
|
|
sub.device->pixels_copy_from(mem, sy, w, sh);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
mem.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
2014-03-26 08:57:30 +00:00
|
|
|
void draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int width, int height, bool transparent,
|
|
|
|
const DeviceDrawParams &draw_params)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
device_ptr tmp = rgba.device_pointer;
|
|
|
|
int i = 0, sub_h = h/devices.size();
|
2011-09-12 13:13:56 +00:00
|
|
|
int sub_height = height/devices.size();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
int sy = y + i*sub_h;
|
|
|
|
int sh = (i == (int)devices.size() - 1)? h - sub_h*i: sub_h;
|
2011-09-12 13:13:56 +00:00
|
|
|
int sheight = (i == (int)devices.size() - 1)? height - sub_height*i: sub_height;
|
2012-01-04 18:06:32 +00:00
|
|
|
int sdy = dy + i*sub_height;
|
2011-04-27 11:58:34 +00:00
|
|
|
/* adjust math for w/width */
|
|
|
|
|
|
|
|
rgba.device_pointer = sub.ptr_map[tmp];
|
2014-03-26 08:57:30 +00:00
|
|
|
sub.device->draw_pixels(rgba, sy, w, sh, sdy, width, sheight, transparent, draw_params);
|
2011-04-27 11:58:34 +00:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
rgba.device_pointer = tmp;
|
|
|
|
}
|
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
void map_tile(Device *sub_device, RenderTile& tile)
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
if(sub.device == sub_device) {
|
|
|
|
if(tile.buffer) tile.buffer = sub.ptr_map[tile.buffer];
|
|
|
|
if(tile.rng_state) tile.rng_state = sub.ptr_map[tile.rng_state];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int device_number(Device *sub_device)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
if(sub.device == sub_device)
|
|
|
|
return i;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-07-22 21:41:01 +00:00
|
|
|
int get_split_task_count(DeviceTask& task)
|
|
|
|
{
|
2014-08-05 16:50:50 +00:00
|
|
|
int total_tasks = 0;
|
|
|
|
list<DeviceTask> tasks;
|
|
|
|
task.split(tasks, devices.size());
|
|
|
|
foreach(SubDevice& sub, devices) {
|
|
|
|
if(!tasks.empty()) {
|
|
|
|
DeviceTask subtask = tasks.front();
|
|
|
|
tasks.pop_front();
|
|
|
|
|
|
|
|
total_tasks += sub.device->get_split_task_count(subtask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return total_tasks;
|
2014-07-22 21:41:01 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
void task_add(DeviceTask& task)
|
|
|
|
{
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
list<DeviceTask> tasks;
|
2011-04-27 11:58:34 +00:00
|
|
|
task.split(tasks, devices.size());
|
|
|
|
|
|
|
|
foreach(SubDevice& sub, devices) {
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
if(!tasks.empty()) {
|
|
|
|
DeviceTask subtask = tasks.front();
|
|
|
|
tasks.pop_front();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
if(task.buffer) subtask.buffer = sub.ptr_map[task.buffer];
|
2013-08-30 23:49:38 +00:00
|
|
|
if(task.rgba_byte) subtask.rgba_byte = sub.ptr_map[task.rgba_byte];
|
|
|
|
if(task.rgba_half) subtask.rgba_half = sub.ptr_map[task.rgba_half];
|
2011-12-31 15:18:13 +00:00
|
|
|
if(task.shader_input) subtask.shader_input = sub.ptr_map[task.shader_input];
|
|
|
|
if(task.shader_output) subtask.shader_output = sub.ptr_map[task.shader_output];
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
sub.device->task_add(subtask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void task_wait()
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
|
|
|
sub.device->task_wait();
|
|
|
|
}
|
|
|
|
|
|
|
|
void task_cancel()
|
|
|
|
{
|
|
|
|
foreach(SubDevice& sub, devices)
|
|
|
|
sub.device->task_cancel();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-11-05 08:04:57 +00:00
|
|
|
Device *device_multi_create(DeviceInfo& info, Stats &stats, bool background)
|
2012-01-04 18:06:32 +00:00
|
|
|
{
|
2012-11-05 08:04:57 +00:00
|
|
|
return new MultiDevice(info, stats, background);
|
2012-01-04 18:06:32 +00:00
|
|
|
}
|
|
|
|
|
2012-02-23 20:27:17 +00:00
|
|
|
static bool device_multi_add(vector<DeviceInfo>& devices, DeviceType type, bool with_display, bool with_advanced_shading, const char *id_fmt, int num)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-01-04 18:06:32 +00:00
|
|
|
DeviceInfo info;
|
|
|
|
|
|
|
|
/* create map to find duplicate descriptions */
|
|
|
|
map<string, int> dupli_map;
|
|
|
|
map<string, int>::iterator dt;
|
2012-01-09 16:58:01 +00:00
|
|
|
int num_added = 0, num_display = 0;
|
2012-01-04 18:06:32 +00:00
|
|
|
|
2012-02-23 20:27:17 +00:00
|
|
|
info.advanced_shading = with_advanced_shading;
|
2012-05-13 12:32:44 +00:00
|
|
|
info.pack_images = false;
|
2014-05-11 01:38:39 +00:00
|
|
|
info.extended_images = true;
|
2012-01-26 19:07:01 +00:00
|
|
|
|
2012-01-04 18:06:32 +00:00
|
|
|
foreach(DeviceInfo& subinfo, devices) {
|
|
|
|
if(subinfo.type == type) {
|
2012-02-23 20:27:17 +00:00
|
|
|
if(subinfo.advanced_shading != info.advanced_shading)
|
|
|
|
continue;
|
2012-01-09 16:58:01 +00:00
|
|
|
if(subinfo.display_device) {
|
|
|
|
if(with_display)
|
|
|
|
num_display++;
|
|
|
|
else
|
|
|
|
continue;
|
2012-01-04 18:06:32 +00:00
|
|
|
}
|
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
string key = subinfo.description;
|
2012-01-04 18:06:32 +00:00
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
if(dupli_map.find(key) == dupli_map.end())
|
|
|
|
dupli_map[key] = 1;
|
|
|
|
else
|
|
|
|
dupli_map[key]++;
|
|
|
|
|
|
|
|
info.multi_devices.push_back(subinfo);
|
|
|
|
if(subinfo.display_device)
|
|
|
|
info.display_device = true;
|
2012-05-13 12:32:44 +00:00
|
|
|
info.pack_images = info.pack_images || subinfo.pack_images;
|
2014-05-11 01:38:39 +00:00
|
|
|
info.extended_images = info.extended_images && subinfo.extended_images;
|
2012-01-09 16:58:01 +00:00
|
|
|
num_added++;
|
2012-01-04 18:06:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
if(num_added <= 1 || (with_display && num_display == 0))
|
2012-02-23 20:27:17 +00:00
|
|
|
return false;
|
2012-01-04 18:06:32 +00:00
|
|
|
|
|
|
|
/* generate string */
|
|
|
|
stringstream desc;
|
|
|
|
vector<string> last_tokens;
|
|
|
|
bool first = true;
|
|
|
|
|
|
|
|
for(dt = dupli_map.begin(); dt != dupli_map.end(); dt++) {
|
|
|
|
if(!first) desc << " + ";
|
|
|
|
first = false;
|
|
|
|
|
|
|
|
/* get name and count */
|
|
|
|
string name = dt->first;
|
|
|
|
int count = dt->second;
|
|
|
|
|
|
|
|
/* strip common prefixes */
|
|
|
|
vector<string> tokens;
|
|
|
|
string_split(tokens, dt->first);
|
|
|
|
|
|
|
|
if(tokens.size() > 1) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 0; i < tokens.size() && i < last_tokens.size(); i++)
|
|
|
|
if(tokens[i] != last_tokens[i])
|
|
|
|
break;
|
|
|
|
|
|
|
|
name = "";
|
|
|
|
for(; i < tokens.size(); i++) {
|
|
|
|
name += tokens[i];
|
|
|
|
if(i != tokens.size() - 1)
|
|
|
|
name += " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
last_tokens = tokens;
|
|
|
|
|
|
|
|
/* add */
|
|
|
|
if(count > 1)
|
|
|
|
desc << name << " (" << count << "x)";
|
|
|
|
else
|
|
|
|
desc << name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add info */
|
|
|
|
info.type = DEVICE_MULTI;
|
|
|
|
info.description = desc.str();
|
|
|
|
info.id = string_printf(id_fmt, num);
|
2012-01-09 16:58:01 +00:00
|
|
|
info.display_device = with_display;
|
2012-01-04 18:06:32 +00:00
|
|
|
info.num = 0;
|
|
|
|
|
2012-01-09 16:58:01 +00:00
|
|
|
if(with_display)
|
|
|
|
devices.push_back(info);
|
|
|
|
else
|
|
|
|
devices.insert(devices.begin(), info);
|
2012-02-23 20:27:17 +00:00
|
|
|
|
|
|
|
return true;
|
2012-01-04 18:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void device_multi_info(vector<DeviceInfo>& devices)
|
|
|
|
{
|
|
|
|
int num = 0;
|
2012-02-23 20:27:17 +00:00
|
|
|
|
|
|
|
if(!device_multi_add(devices, DEVICE_CUDA, false, true, "CUDA_MULTI_%d", num++))
|
|
|
|
device_multi_add(devices, DEVICE_CUDA, false, false, "CUDA_MULTI_%d", num++);
|
|
|
|
if(!device_multi_add(devices, DEVICE_CUDA, true, true, "CUDA_MULTI_%d", num++))
|
|
|
|
device_multi_add(devices, DEVICE_CUDA, true, false, "CUDA_MULTI_%d", num++);
|
2012-01-04 18:06:32 +00:00
|
|
|
|
|
|
|
num = 0;
|
2012-02-23 20:27:17 +00:00
|
|
|
if(!device_multi_add(devices, DEVICE_OPENCL, false, true, "OPENCL_MULTI_%d", num++))
|
|
|
|
device_multi_add(devices, DEVICE_OPENCL, false, false, "OPENCL_MULTI_%d", num++);
|
|
|
|
if(!device_multi_add(devices, DEVICE_OPENCL, true, true, "OPENCL_MULTI_%d", num++))
|
|
|
|
device_multi_add(devices, DEVICE_OPENCL, true, false, "OPENCL_MULTI_%d", num++);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|