Patches: faster array dump and CL compile error messages

xshisdi32
Mausschubser
Mausschubser
Beiträge: 73
Registriert: 10. Apr 2011 17:24
Wohnort: Bessungen, Darmstadt
Kontaktdaten:

Patches: faster array dump and CL compile error messages

Beitrag von xshisdi32 » 19. Jan 2012 00:29

These patches are not concerned with the actual assignment, that's why I post them here. Patches can be applied with patch (1) or manually by reading the line number before the "a" and appending the lines after that line.

Faster array dumping
The original template is dumping the MI result matrix using Matrix::print. This method is very slow on my machine, however:

Code: Alles auswählen

janus@Zeus:/media/sda1/Users/Janus/Documents/My Dropbox/TUD/gdi3/praktikum5/code/build$ time ./Praktikum5 -i=fasta -cpu
inpath: fasta
MI outpath: fasta.MI.out
computing on the CPU
[...]
execution time: 4988 milliseconds
writing output to fasta.MI.out

real	0m51.705s
user	0m8.497s
sys	0m4.472s
The reason is that the endl in Matrix::print will flush the ostream. Replace the endl with a "\n" and you get a performance bump:

Code: Alles auswählen

real	0m6.724s
user	0m4.664s
sys	0m0.044s
CL compile error messages
The original template doesn't ask for CL compiler error messages. Here's a patch for dumping those:

oclutil.cpp:

Code: Alles auswählen

12a13
> #include <stdexcept>
77a77,99
> 
> 		if (oclError == CL_BUILD_PROGRAM_FAILURE) {
> 			size_t length;
> 			oclError = clGetProgramBuildInfo(oclProgram,
> 				oclDevice,
> 				CL_PROGRAM_BUILD_LOG,
> 				0,
> 				NULL,
> 				&length);
> 			if(oclError != CL_SUCCESS)
> 				throw std::runtime_error("Can't get program build info (clGetProgramBuildInfo)");
> 	
> 			char* buffer = (char*)malloc(length);
> 			oclError = clGetProgramBuildInfo(oclProgram,
> 				oclDevice,
> 				CL_PROGRAM_BUILD_LOG,
> 				length,
> 				buffer,
> 				NULL);
> 	
> 			throw std::runtime_error(buffer);
> 		}
> 

Zurück zu „Archiv“