This example demonstrates how to use preprocessor macros to distinguish between the host and the device compilation pass(es). For more information on this topic, please refer to the HIP documentation.
- A kernel is launched called which calls a printer function.
- The device and the host are synchronized.
- The printer function is called on the host.
__HIP_DEVICE_COMPILE__is defined whenever a device compilation pass takes place. It is undefined otherwise.
__HIP_DEVICE_COMPILE__printf
hipDeviceSynchronize