| 470 | } |
| 471 | |
| 472 | void runSingleTest(const char *ref_file, const char *exec_path) |
| 473 | { |
| 474 | bool bTestResult = true; |
| 475 | |
| 476 | uint *d_output; |
| 477 | checkCudaErrors(cudaMalloc((void **)&d_output, width * height * sizeof(uint))); |
| 478 | checkCudaErrors(cudaMemset(d_output, 0, width * height * sizeof(uint))); |
| 479 | |
| 480 | float modelView[16] = { |
| 481 | 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 4.0f, 1.0f}; |
| 482 | |
| 483 | invViewMatrix[0] = modelView[0]; |
| 484 | invViewMatrix[1] = modelView[4]; |
| 485 | invViewMatrix[2] = modelView[8]; |
| 486 | invViewMatrix[3] = modelView[12]; |
| 487 | invViewMatrix[4] = modelView[1]; |
| 488 | invViewMatrix[5] = modelView[5]; |
| 489 | invViewMatrix[6] = modelView[9]; |
| 490 | invViewMatrix[7] = modelView[13]; |
| 491 | invViewMatrix[8] = modelView[2]; |
| 492 | invViewMatrix[9] = modelView[6]; |
| 493 | invViewMatrix[10] = modelView[10]; |
| 494 | invViewMatrix[11] = modelView[14]; |
| 495 | |
| 496 | // call CUDA kernel, writing results to PBO |
| 497 | copyInvViewMatrix(invViewMatrix, sizeof(float4) * 3); |
| 498 | |
| 499 | // Start timer 0 and process n loops on the GPU |
| 500 | int nIter = 10; |
| 501 | |
| 502 | for (int i = -1; i < nIter; i++) { |
| 503 | if (i == 0) { |
| 504 | cudaDeviceSynchronize(); |
| 505 | sdkStartTimer(&timer); |
| 506 | } |
| 507 | |
| 508 | render_kernel(gridSize, blockSize, d_output, width, height, density, brightness, transferOffset, transferScale); |
| 509 | } |
| 510 | |
| 511 | cudaDeviceSynchronize(); |
| 512 | sdkStopTimer(&timer); |
| 513 | // Get elapsed time and throughput, then log to sample and master logs |
| 514 | double dAvgTime = sdkGetTimerValue(&timer) / (nIter * 1000.0); |
| 515 | printf("volumeRender, Throughput = %.4f MTexels/s, Time = %.5f s, Size = %u " |
| 516 | "Texels, NumDevsUsed = %u, Workgroup = %u\n", |
| 517 | (1.0e-6 * width * height) / dAvgTime, |
| 518 | dAvgTime, |
| 519 | (width * height), |
| 520 | 1, |
| 521 | blockSize.x * blockSize.y); |
| 522 | |
| 523 | getLastCudaError("Error: render_kernel() execution FAILED"); |
| 524 | checkCudaErrors(cudaDeviceSynchronize()); |
| 525 | |
| 526 | unsigned char *h_output = (unsigned char *)malloc(width * height * 4); |
| 527 | checkCudaErrors(cudaMemcpy(h_output, d_output, width * height * 4, cudaMemcpyDeviceToHost)); |
| 528 | |
| 529 | sdkSavePPM4ub("volume.ppm", h_output, width, height); |
no test coverage detected