HPC Magazine February 2014 - Discovering OpenACC 2.0 - part II

Listing 8: Routine customization for multiple hardware targets.


//--- File sum_nvidia.c will only be used when targeting NVIDIA accelerators

#pragma acc routine worker 
void sum_for_nvidia(int n , float *A) 
{
	// here comes the ACC code tuned for NVIDIA targets
}

//--- File sum_radeon.c will only be used when targeting Radeon accelerators

#pragma acc routine worker 
void sum_for_radeon(int n , float *A) 
{
  // here comes the ACC code tuned for Radeon targets
}

//--- in file sum.h

#pragma acc routine worker \
  dtype(NVIDIA) bind(sum_for_nvidia) \
  dtype(RADEON) bind(sum_for_radeon)
void sum(int n , float *A) ;