init() and close()

Two other members, which are not listed in Table 2, should be mentioned. These are the functions init() and close(). These functions are called by process() before and after the routines have been executed. Each of the classes Hybrid_, DefaultCPU and DefaultGPU are equipped with these members, but the former merely calls those of its parents. That is, Hybrid_'s init() and close() members will call those of DefaultCPU and DefaultGPU, in that order.

By default, the init() implementation in DefaultCPU only calls the private member setMemSizes(), which sets the memory-size variables based on the input. This means that when the size of an input or output-variable is bound in the specification-file to some symbol (vectorSize in the example of Section 4), the symbol will be assigned the value corresponding to the size of the input. The default implementation of DefaultGPU::init() does absolutely nothing.

The default implementation of DefaultGPU::close() however, makes sure that the device and host are synchronized before returning from process() by calling
cudaDeviceSynchronize(). In contrast, DefaultCPU::close() is an empty function by default.



Joren Heit 2013-12-17