bool ImageBufAlgo::checker (ImageBuf &dst, int width, int height, int depth, const float *color1, const float *color2, int xoffset, int yoffset, int zoffset, ROI roi, int nthreads) { if (! IBAprep (roi, &dst)) return false; OIIO_DISPATCH_TYPES ("checker", checker_, dst.spec().format, dst, Dim3(width, height, depth), color1, color2, Dim3(xoffset, yoffset, zoffset), roi, nthreads); return true; }
////////////////////////////////// // Function to parse the memory access trace (input) ////////////////////////////////// Dim3 read_file(std::vector<Thread> &threads, const std::string kernelname, const std::string benchname, const std::string suitename) { unsigned num_threads = 0; unsigned num_accesses = 0; std::string filename = trace_dir+"/"+suitename+"/"+benchname+"/"+kernelname+".trc"; // Test if the file exists, return if it does not exist std::ifstream exists_file(filename); if (!exists_file) { return Dim3({0,0,0}); } // Open the file for reading std::cout << SPLIT_STRING << std::endl; message(""); std::cout << "### Reading the trace file for '" << kernelname << "'..."; std::ifstream input_file(filename); // First get the blocksize from the trace file std::string temp_string; Dim3 blockdim; input_file >> temp_string >> blockdim.x >> blockdim.y >> blockdim.z; // Then proceed to the actual trace data unsigned thread, direction, bytes; unsigned long address; unsigned pc, block; while (input_file >> thread >> address >> bytes >> pc >> block) { direction = 0; // Consider only loads (stores are not cached in Fermi's L1 caches) if (direction == 0) { // Count the number of accesses and threads num_accesses++; num_threads = (num_threads > thread) ? num_threads : thread + 1; // Store the data in the Thread class Access access = { direction, address, 1, bytes, address+bytes-1, pc, block }; if (access.address == 0) access.width = 0; threads[thread].append_access(access); } } std::cout << "done" << std::endl; // Test if the file actually contained memory accesses - exit otherwise if (!(num_accesses > 0 && num_threads > 0)) { std::cout << "### Error: '" << filename << "' is not a valid memory access trace" << std::endl; message(""); return Dim3({0,0,0}); } // Reduce the size of the threads vector threads.resize(num_threads); threads.shrink_to_fit(); // Print additional information and return the threadblock dimensions std::cout << "### Blocksize: (" << blockdim.x << "," << blockdim.y << "," << blockdim.z << ")" << std::endl; std::cout << "### Total threads: " << num_threads << std::endl; std::cout << "### Total memory accesses: " << num_accesses << "" << std::endl; return blockdim; }