Refactor: Cycles: Avoid unnecessary newlines in Metal logs
Pull Request: https://projects.blender.org/blender/blender/pulls/140244
This commit is contained in:
@@ -25,7 +25,7 @@ CCL_NAMESPACE_BEGIN
|
||||
{ \
|
||||
string str = string_printf(__VA_ARGS__); \
|
||||
progress.set_substatus(str); \
|
||||
metal_printf("%s\n", str.c_str()); \
|
||||
metal_printf("%s", str.c_str()); \
|
||||
}
|
||||
|
||||
// # define BVH_THROTTLE_DIAGNOSTICS
|
||||
|
||||
@@ -86,7 +86,7 @@ MetalDevice::MetalDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
|
||||
auto usable_devices = MetalInfo::get_usable_devices();
|
||||
assert(mtlDevId < usable_devices.size());
|
||||
mtlDevice = usable_devices[mtlDevId];
|
||||
metal_printf("Creating new Cycles Metal device: %s\n", info.description.c_str());
|
||||
metal_printf("Creating new Cycles Metal device: %s", info.description.c_str());
|
||||
|
||||
/* Ensure that back-compatability helpers for getting gpuAddress & gpuResourceID are set up. */
|
||||
metal_gpu_address_helper_init(mtlDevice);
|
||||
@@ -156,7 +156,7 @@ MetalDevice::MetalDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
|
||||
if (auto *envstr = getenv("CYCLES_METAL_SPECIALIZATION_LEVEL")) {
|
||||
kernel_specialization_level = (MetalPipelineType)atoi(envstr);
|
||||
}
|
||||
metal_printf("kernel_specialization_level = %s\n",
|
||||
metal_printf("kernel_specialization_level = %s",
|
||||
kernel_type_as_string(
|
||||
(MetalPipelineType)min((int)kernel_specialization_level, (int)PSO_NUM - 1)));
|
||||
|
||||
@@ -310,7 +310,7 @@ string MetalDevice::preprocess_source(MetalPipelineType pso_type,
|
||||
# undef KERNEL_STRUCT_MEMBER_DONT_SPECIALIZE
|
||||
# undef KERNEL_STRUCT_BEGIN
|
||||
|
||||
metal_printf("KernelData patching took %.1f ms\n", (time_dt() - starttime) * 1000.0);
|
||||
metal_printf("KernelData patching took %.1f ms", (time_dt() - starttime) * 1000.0);
|
||||
}
|
||||
|
||||
/* Opt in to all of available specializations. This can be made more granular for the
|
||||
@@ -433,7 +433,7 @@ void MetalDevice::compile_and_load(const int device_id, MetalPipelineType pso_ty
|
||||
/* Check whether the device still exists. */
|
||||
MetalDevice *instance = get_device_by_ID(device_id, lock);
|
||||
if (!instance) {
|
||||
metal_printf("Ignoring %s compilation request - device no longer exists\n",
|
||||
metal_printf("Ignoring %s compilation request - device no longer exists",
|
||||
kernel_type_as_string(pso_type));
|
||||
return;
|
||||
}
|
||||
@@ -441,7 +441,7 @@ void MetalDevice::compile_and_load(const int device_id, MetalPipelineType pso_ty
|
||||
if (!MetalDeviceKernels::should_load_kernels(instance, pso_type)) {
|
||||
/* We already have a full set of matching pipelines which are cached or queued. Return
|
||||
* early to avoid redundant MTLLibrary compilation. */
|
||||
metal_printf("Ignoreing %s compilation request - kernels already requested\n",
|
||||
metal_printf("Ignoreing %s compilation request - kernels already requested",
|
||||
kernel_type_as_string(pso_type));
|
||||
return;
|
||||
}
|
||||
@@ -482,7 +482,7 @@ void MetalDevice::compile_and_load(const int device_id, MetalPipelineType pso_ty
|
||||
options:options
|
||||
error:&error];
|
||||
|
||||
metal_printf("Front-end compilation finished in %.1f seconds (%s)\n",
|
||||
metal_printf("Front-end compilation finished in %.1f seconds (%s)",
|
||||
time_dt() - starttime,
|
||||
kernel_type_as_string(pso_type));
|
||||
|
||||
@@ -521,7 +521,7 @@ void MetalDevice::compile_and_load(const int device_id, MetalPipelineType pso_ty
|
||||
if (starttime && blocking_pso_build) {
|
||||
MetalDeviceKernels::wait_for_all();
|
||||
|
||||
metal_printf("Back-end compilation finished in %.1f seconds (%s)\n",
|
||||
metal_printf("Back-end compilation finished in %.1f seconds (%s)",
|
||||
time_dt() - starttime,
|
||||
kernel_type_as_string(pso_type));
|
||||
}
|
||||
@@ -807,7 +807,7 @@ bool MetalDevice::is_ready(string &status) const
|
||||
status = "Using optimized kernels";
|
||||
}
|
||||
|
||||
metal_printf("MetalDevice::is_ready(...) --> true\n");
|
||||
metal_printf("MetalDevice::is_ready(...) --> true");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -848,7 +848,7 @@ void MetalDevice::optimize_for_scene(Scene *scene)
|
||||
specialize_kernels_fn);
|
||||
}
|
||||
else {
|
||||
metal_printf("\"optimize_for_scene\" request already in flight - dropping request\n");
|
||||
metal_printf("\"optimize_for_scene\" request already in flight - dropping request");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -170,12 +170,12 @@ ShaderCache::~ShaderCache()
|
||||
running = false;
|
||||
cond_var.notify_all();
|
||||
|
||||
metal_printf("Waiting for ShaderCache threads... (incomplete_requests = %d)\n",
|
||||
metal_printf("Waiting for ShaderCache threads... (incomplete_requests = %d)",
|
||||
int(incomplete_requests));
|
||||
for (auto &thread : compile_threads) {
|
||||
thread.join();
|
||||
}
|
||||
metal_printf("ShaderCache shut down.\n");
|
||||
metal_printf("ShaderCache shut down.");
|
||||
}
|
||||
|
||||
void ShaderCache::wait_for_all()
|
||||
@@ -208,7 +208,7 @@ void ShaderCache::compile_thread_func()
|
||||
|
||||
if (MetalDevice::is_device_cancelled(pipeline->originating_device_id)) {
|
||||
/* The originating MetalDevice is no longer active, so this request is obsolete. */
|
||||
metal_printf("Cancelling compilation of %s (%s)\n",
|
||||
metal_printf("Cancelling compilation of %s (%s)",
|
||||
device_kernel_as_string(device_kernel),
|
||||
kernel_type_as_string(pso_type));
|
||||
}
|
||||
@@ -225,7 +225,7 @@ void ShaderCache::compile_thread_func()
|
||||
if (collection[i]->pso_type == pso_type) {
|
||||
max_entries_of_same_pso_type -= 1;
|
||||
if (max_entries_of_same_pso_type == 0) {
|
||||
metal_printf("Purging oldest %s:%s kernel from ShaderCache\n",
|
||||
metal_printf("Purging oldest %s:%s kernel from ShaderCache",
|
||||
kernel_type_as_string(pso_type),
|
||||
device_kernel_as_string(device_kernel));
|
||||
collection.erase(collection.begin() + i);
|
||||
@@ -318,7 +318,7 @@ void ShaderCache::load_kernel(DeviceKernel device_kernel,
|
||||
}
|
||||
# endif
|
||||
|
||||
metal_printf("Spawning %d Cycles kernel compilation threads\n", max_mtlcompiler_threads);
|
||||
metal_printf("Spawning %d Cycles kernel compilation threads", max_mtlcompiler_threads);
|
||||
for (int i = 0; i < max_mtlcompiler_threads; i++) {
|
||||
compile_threads.emplace_back([this] { this->compile_thread_func(); });
|
||||
}
|
||||
@@ -385,7 +385,7 @@ MetalKernelPipeline *ShaderCache::get_best_pipeline(DeviceKernel kernel, const M
|
||||
|
||||
if (best_match) {
|
||||
if (best_match->usage_count == 0 && best_match->pso_type != PSO_GENERIC) {
|
||||
metal_printf("Swapping in %s version of %s\n",
|
||||
metal_printf("Swapping in %s version of %s",
|
||||
kernel_type_as_string(best_match->pso_type),
|
||||
device_kernel_as_string(kernel));
|
||||
}
|
||||
@@ -694,7 +694,7 @@ void MetalKernelPipeline::compile()
|
||||
archive = [mtlDevice newBinaryArchiveWithDescriptor:archiveDesc error:&error];
|
||||
if (!archive) {
|
||||
const char *err = error ? [[error localizedDescription] UTF8String] : nullptr;
|
||||
metal_printf("newBinaryArchiveWithDescriptor failed: %s\n", err ? err : "nil");
|
||||
metal_printf("newBinaryArchiveWithDescriptor failed: %s", err ? err : "nil");
|
||||
}
|
||||
[archiveDesc release];
|
||||
|
||||
@@ -760,7 +760,7 @@ void MetalKernelPipeline::compile()
|
||||
error:&error])
|
||||
{
|
||||
NSString *errStr = [error localizedDescription];
|
||||
metal_printf("Failed to add PSO to archive:\n%s\n", errStr ? [errStr UTF8String] : "nil");
|
||||
metal_printf("Failed to add PSO to archive:\n%s", errStr ? [errStr UTF8String] : "nil");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -793,7 +793,7 @@ void MetalKernelPipeline::compile()
|
||||
double duration = time_dt() - starttime;
|
||||
|
||||
if (pipeline == nil) {
|
||||
metal_printf("%16s | %2d | %-55s | %7.2fs | FAILED!\n",
|
||||
metal_printf("%16s | %2d | %-55s | %7.2fs | FAILED!",
|
||||
kernel_type_as_string(pso_type),
|
||||
device_kernel,
|
||||
device_kernel_as_string(device_kernel),
|
||||
@@ -811,7 +811,7 @@ void MetalKernelPipeline::compile()
|
||||
if (creating_new_archive || recreate_archive) {
|
||||
if (![archive serializeToURL:[NSURL fileURLWithPath:@(metalbin_path.c_str())] error:&error])
|
||||
{
|
||||
metal_printf("Failed to save binary archive to %s, error:\n%s\n",
|
||||
metal_printf("Failed to save binary archive to %s, error:\n%s",
|
||||
metalbin_path.c_str(),
|
||||
[[error localizedDescription] UTF8String]);
|
||||
}
|
||||
@@ -826,14 +826,14 @@ void MetalKernelPipeline::compile()
|
||||
computePipelineStateDescriptor = nil;
|
||||
|
||||
if (!use_binary_archive) {
|
||||
metal_printf("%16s | %2d | %-55s | %7.2fs\n",
|
||||
metal_printf("%16s | %2d | %-55s | %7.2fs",
|
||||
kernel_type_as_string(pso_type),
|
||||
int(device_kernel),
|
||||
device_kernel_as_string(device_kernel),
|
||||
duration);
|
||||
}
|
||||
else {
|
||||
metal_printf("%16s | %2d | %-55s | %7.2fs | %s: %s\n",
|
||||
metal_printf("%16s | %2d | %-55s | %7.2fs | %s: %s",
|
||||
kernel_type_as_string(pso_type),
|
||||
device_kernel,
|
||||
device_kernel_as_string(device_kernel),
|
||||
|
||||
@@ -285,7 +285,7 @@ int MetalDeviceQueue::num_concurrent_states(const size_t state_size) const
|
||||
size_t total_state_size = result * state_size;
|
||||
if (max_recommended_working_set - allocated_so_far - total_state_size * 2 >= min_headroom) {
|
||||
result *= 2;
|
||||
metal_printf("Doubling state count to exploit available RAM (new size = %d)\n", result);
|
||||
metal_printf("Doubling state count to exploit available RAM (new size = %d)", result);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -87,7 +87,7 @@ const vector<id<MTLDevice>> &MetalInfo::get_usable_devices()
|
||||
return usable_devices;
|
||||
}
|
||||
|
||||
metal_printf("Usable Metal devices:\n");
|
||||
metal_printf("Usable Metal devices:");
|
||||
for (id<MTLDevice> device in MTLCopyAllDevices()) {
|
||||
string device_name = get_device_name(device);
|
||||
bool usable = false;
|
||||
@@ -105,16 +105,16 @@ const vector<id<MTLDevice>> &MetalInfo::get_usable_devices()
|
||||
}
|
||||
|
||||
if (usable) {
|
||||
metal_printf("- %s\n", device_name.c_str());
|
||||
metal_printf("- %s", device_name.c_str());
|
||||
[device retain];
|
||||
usable_devices.push_back(device);
|
||||
}
|
||||
else {
|
||||
metal_printf(" (skipping \"%s\")\n", device_name.c_str());
|
||||
metal_printf(" (skipping \"%s\")", device_name.c_str());
|
||||
}
|
||||
}
|
||||
if (usable_devices.empty()) {
|
||||
metal_printf(" No usable Metal devices found\n");
|
||||
metal_printf(" No usable Metal devices found");
|
||||
}
|
||||
already_enumerated = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user