[Bf-blender-cvs] [1618329] master: Code cleanup: style, require ; for cuda_assert, opencl_assert

Campbell Barton noreply at git.blender.org
Sat May 3 20:01:37 CEST 2014


Commit: 1618329b005beca2dfbe413a4eef661a83ad15a1
Author: Campbell Barton
Date:   Sun May 4 03:49:56 2014 +1000
https://developer.blender.org/rB1618329b005beca2dfbe413a4eef661a83ad15a1

Code cleanup: style, require ; for cuda_assert, opencl_assert

===================================================================

M	intern/cycles/app/cycles_standalone.cpp
M	intern/cycles/device/device_cuda.cpp
M	intern/cycles/device/device_opencl.cpp

===================================================================

diff --git a/intern/cycles/app/cycles_standalone.cpp b/intern/cycles/app/cycles_standalone.cpp
index 074d640..9871273 100644
--- a/intern/cycles/app/cycles_standalone.cpp
+++ b/intern/cycles/app/cycles_standalone.cpp
@@ -177,8 +177,14 @@ static void display_info(Progress& progress)
 
 	interactive = options.interactive? "On":"Off";
 
-	str = string_printf("%s        Time: %.2f        Latency: %.4f        Sample: %d        Average: %.4f        Interactive: %s",
-						status.c_str(), total_time, latency, sample, sample_time, interactive.c_str());
+	str = string_printf(
+	        "%s"
+	        "        Time: %.2f"
+	        "        Latency: %.4f"
+	        "        Sample: %d"
+	        "        Average: %.4f"
+	        "        Interactive: %s",
+	        status.c_str(), total_time, latency, sample, sample_time, interactive.c_str());
 
 	view_display_info(str.c_str());
 
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 0257153..29b348d 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -139,7 +139,7 @@ public:
 			/*cuda_abort();*/ \
 			cuda_error_documentation(); \
 		} \
-	}
+	} (void)0
 
 	bool cuda_error_(CUresult result, const string& stmt)
 	{
@@ -166,7 +166,7 @@ public:
 
 	void cuda_push_context()
 	{
-		cuda_assert(cuCtxSetCurrent(cuContext))
+		cuda_assert(cuCtxSetCurrent(cuContext));
 	}
 
 	void cuda_pop_context()
@@ -174,7 +174,7 @@ public:
 		cuda_assert(cuCtxSetCurrent(NULL));
 	}
 
-    CUDADevice(DeviceInfo& info, Stats &stats, bool background_)
+	CUDADevice(DeviceInfo& info, Stats &stats, bool background_)
 	: Device(info, stats, background_)
 	{
 		first_error = true;
@@ -212,8 +212,8 @@ public:
 		if(cuda_error_(result, "cuCtxCreate"))
 			return;
 
-		cuda_assert(cuStreamCreate(&cuStream, 0))
-		cuda_assert(cuEventCreate(&tileDone, 0x1))
+		cuda_assert(cuStreamCreate(&cuStream, 0));
+		cuda_assert(cuEventCreate(&tileDone, 0x1));
 
 		int major, minor;
 		cuDeviceComputeCapability(&major, &minor, cuDevId);
@@ -231,9 +231,9 @@ public:
 	{
 		task_pool.stop();
 
-		cuda_assert(cuEventDestroy(tileDone))
-		cuda_assert(cuStreamDestroy(cuStream))
-		cuda_assert(cuCtxDestroy(cuContext))
+		cuda_assert(cuEventDestroy(tileDone));
+		cuda_assert(cuStreamDestroy(cuStream));
+		cuda_assert(cuCtxDestroy(cuContext));
 	}
 
 	bool support_device(bool experimental, bool branched)
@@ -376,7 +376,7 @@ public:
 		cuda_push_context();
 		CUdeviceptr device_pointer;
 		size_t size = mem.memory_size();
-		cuda_assert(cuMemAlloc(&device_pointer, size))
+		cuda_assert(cuMemAlloc(&device_pointer, size));
 		mem.device_pointer = (device_ptr)device_pointer;
 		stats.mem_alloc(size);
 		cuda_pop_context();
@@ -386,7 +386,7 @@ public:
 	{
 		cuda_push_context();
 		if(mem.device_pointer)
-			cuda_assert(cuMemcpyHtoD(cuda_device_ptr(mem.device_pointer), (void*)mem.data_pointer, mem.memory_size()))
+			cuda_assert(cuMemcpyHtoD(cuda_device_ptr(mem.device_pointer), (void*)mem.data_pointer, mem.memory_size()));
 		cuda_pop_context();
 	}
 
@@ -398,7 +398,7 @@ public:
 		cuda_push_context();
 		if(mem.device_pointer) {
 			cuda_assert(cuMemcpyDtoH((uchar*)mem.data_pointer + offset,
-				(CUdeviceptr)((uchar*)mem.device_pointer + offset), size))
+			                         (CUdeviceptr)((uchar*)mem.device_pointer + offset), size));
 		}
 		else {
 			memset((char*)mem.data_pointer + offset, 0, size);
@@ -412,7 +412,7 @@ public:
 
 		cuda_push_context();
 		if(mem.device_pointer)
-			cuda_assert(cuMemsetD8(cuda_device_ptr(mem.device_pointer), 0, mem.memory_size()))
+			cuda_assert(cuMemsetD8(cuda_device_ptr(mem.device_pointer), 0, mem.memory_size()));
 		cuda_pop_context();
 	}
 
@@ -420,7 +420,7 @@ public:
 	{
 		if(mem.device_pointer) {
 			cuda_push_context();
-			cuda_assert(cuMemFree(cuda_device_ptr(mem.device_pointer)))
+			cuda_assert(cuMemFree(cuda_device_ptr(mem.device_pointer)));
 			cuda_pop_context();
 
 			mem.device_pointer = 0;
@@ -435,9 +435,9 @@ public:
 		size_t bytes;
 
 		cuda_push_context();
-		cuda_assert(cuModuleGetGlobal(&mem, &bytes, cuModule, name))
+		cuda_assert(cuModuleGetGlobal(&mem, &bytes, cuModule, name));
 		//assert(bytes == size);
-		cuda_assert(cuMemcpyHtoD(mem, host, size))
+		cuda_assert(cuMemcpyHtoD(mem, host, size));
 		cuda_pop_context();
 	}
 
@@ -464,7 +464,7 @@ public:
 			CUtexref texref = NULL;
 
 			cuda_push_context();
-			cuda_assert(cuModuleGetTexRef(&texref, cuModule, name))
+			cuda_assert(cuModuleGetTexRef(&texref, cuModule, name));
 
 			if(!texref) {
 				cuda_pop_context();
@@ -480,7 +480,7 @@ public:
 				desc.Format = format;
 				desc.NumChannels = mem.data_elements;
 
-				cuda_assert(cuArrayCreate(&handle, &desc))
+				cuda_assert(cuArrayCreate(&handle, &desc));
 
 				if(!handle) {
 					cuda_pop_context();
@@ -498,23 +498,23 @@ public:
 					param.WidthInBytes = param.srcPitch;
 					param.Height = mem.data_height;
 
-					cuda_assert(cuMemcpy2D(&param))
+					cuda_assert(cuMemcpy2D(&param));
 				}
 				else
-					cuda_assert(cuMemcpyHtoA(handle, 0, (void*)mem.data_pointer, size))
+					cuda_assert(cuMemcpyHtoA(handle, 0, (void*)mem.data_pointer, size));
 
-				cuda_assert(cuTexRefSetArray(texref, handle, CU_TRSA_OVERRIDE_FORMAT))
+				cuda_assert(cuTexRefSetArray(texref, handle, CU_TRSA_OVERRIDE_FORMAT));
 
 				if(interpolation == INTERPOLATION_CLOSEST) {
-					cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT))
+					cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT));
 				}
 				else if (interpolation == INTERPOLATION_LINEAR){
-					cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR))
+					cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR));
 				}
 				else {/* CUBIC and SMART are unsupported for CUDA */
-					cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR))
+					cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_LINEAR));
 				}
-				cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_NORMALIZED_COORDINATES))
+				cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_NORMALIZED_COORDINATES));
 
 				mem.device_pointer = (device_ptr)handle;
 
@@ -528,20 +528,20 @@ public:
 
 				cuda_push_context();
 
-				cuda_assert(cuTexRefSetAddress(NULL, texref, cuda_device_ptr(mem.device_pointer), size))
-				cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT))
-				cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_READ_AS_INTEGER))
+				cuda_assert(cuTexRefSetAddress(NULL, texref, cuda_device_ptr(mem.device_pointer), size));
+				cuda_assert(cuTexRefSetFilterMode(texref, CU_TR_FILTER_MODE_POINT));
+				cuda_assert(cuTexRefSetFlags(texref, CU_TRSF_READ_AS_INTEGER));
 			}
 
 			if(periodic) {
-				cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_WRAP))
-				cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_WRAP))
+				cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_WRAP));
+				cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_WRAP));
 			}
 			else {
-				cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_CLAMP))
-				cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_CLAMP))
+				cuda_assert(cuTexRefSetAddressMode(texref, 0, CU_TR_ADDRESS_MODE_CLAMP));
+				cuda_assert(cuTexRefSetAddressMode(texref, 1, CU_TR_ADDRESS_MODE_CLAMP));
 			}
-			cuda_assert(cuTexRefSetFormat(texref, format, mem.data_elements))
+			cuda_assert(cuTexRefSetFormat(texref, format, mem.data_elements));
 
 			cuda_pop_context();
 		}
@@ -554,17 +554,17 @@ public:
 			CUdeviceptr cumem;
 			size_t cubytes;
 
-			cuda_assert(cuModuleGetGlobal(&cumem, &cubytes, cuModule, name))
+			cuda_assert(cuModuleGetGlobal(&cumem, &cubytes, cuModule, name));
 
 			if(cubytes == 8) {
 				/* 64 bit device pointer */
 				uint64_t ptr = mem.device_pointer;
-				cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes))
+				cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes));
 			}
 			else {
 				/* 32 bit device pointer */
 				uint32_t ptr = (uint32_t)mem.device_pointer;
-				cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes))
+				cuda_assert(cuMemcpyHtoD(cumem, (void*)&ptr, cubytes));
 			}
 
 			cuda_pop_context();
@@ -605,10 +605,12 @@ public:
 		CUdeviceptr d_rng_state = cuda_device_ptr(rtile.rng_state);
 
 		/* get kernel function */
-		if(branched && support_device(true, branched))
-			cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_branched_path_trace"))
-		else
-			cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_path_trace"))
+		if(branched && support_device(true, branched)) {
+			cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_branched_path_trace"));
+		}
+		else {
+			cuda_assert(cuModuleGetFunction(&cuPathTrace, cuModule, "kernel_cuda_path_trace"));
+		}
 
 		if(have_error())
 			return;
@@ -616,43 +618,43 @@ public:
 		/* pass in parameters */
 		int offset = 0;
 		
-		cuda_assert(cuParamSetv(cuPathTrace, offset, &d_buffer, sizeof(d_buffer)))
+		cuda_assert(cuParamSetv(cuPathTrace, offset, &d_buffer, sizeof(d_buffer)));
 		offset += sizeof(d_buffer);
 
-		cuda_assert(cuParamSetv(cuPathTrace, offset, &d_rng_state, sizeof(d_rng_state)))
+		cuda_assert(cuParamSetv(cuPathTrace, offset, &d_rng_state, sizeof(d_rng_state)));
 		offset += sizeof(d_rng_state);
 
 		offset = align_up(offset, __alignof(sample));
 
-		cuda_assert(cuParamSeti(cuPathTrace, offset, sample))
+		cuda_assert(cuParamSeti(cuPathTrace, offset, sample));
 		offset += sizeof(sample);
 
-		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.x))
+		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.x));
 		offset += sizeof(rtile.x);
 
-		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.y))
+		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.y));
 		offset += sizeof(rtile.y);
 
-		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.w))
+		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.w));
 		offset += sizeof(rtile.w);
 
-		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.h))
+		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.h));
 		offset += sizeof(rtile.h);
 
-		cuda_assert(cuParamSeti(cuPathTrace, offset, rtile.offset))
+		

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list