HPC Magazine Février 2014 - Maîtriser OpenACC 2.0 (partie 2)

Listing 8 - Spécialisation d’une routine pour différentes cibles matérielles.


//--- 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) ;