On 06/17/2016 07:42 AM, Jakub Jelinek wrote: > On Wed, Jun 15, 2016 at 08:12:15PM -0700, Cesar Philippidis wrote: >> The second set of changes involves teaching the gimplifier to error when >> it detects a function call to an non-acc routines inside an OpenACC >> offloaded region. Actually, I relaxed non-acc routines by excluding >> calls to builtin functions, including those prefixed with _gfortran_. >> Nvptx does have a newlib c library, and it also has a subset of >> libgfortran. Still, this solution is probably not optimal. > > I don't really like that, hardcoding prefixes or whatever is available > (you have quite some subset of libc, libm etc. available too) in the > compiler looks very hackish. What is wrong with complaining during > linking of the offloaded code? Wouldn't the error get reported multiple times then, i.e. once per target? Then again, maybe this error could have been restrained to the host compiler. Anyway, this patch now reduces that error to a warning. Furthermore, that warning is being thrown in lower_omp_1 instead of gimplify_call_expr because the latter is called multiple times and that causes duplicate warnings. The only bit of fallout I had with this change was with the fortran FE's usage of BUILT_IN_EXPECT in gfc_{un}likely. Since these are generated implicitly by the FE, I just added an oacc_function attribute to those calls when flag_openacc is set. >> Next, I had to modify the openacc header files in libgomp to mark >> acc_on_device as an acc routine. Unfortunately, this meant that I had to >> build the opeancc.mod module for gfortran with -fopenacc. But doing >> that, caused caused gcc to stream offloaded code to the openacc.o object >> file. So, I've updated the behavior of flag_generate_offload such that >> minus one indicates that the user specified -foffload=disable, and that >> will prevent gcc from streaming offloaded lto code. The alternative was >> to hack libtool to build libgomp with -foffload=disable. > > This also looks wrong. I'd say the right thing is when loading modules > that have OpenACC bits set in it (and also OpenMP bits, I admit I haven't > handled this well) into CU with the corresponding flags unset (-fopenacc, > -fopenmp, -fopenmp-simd here, depending on which bit it is), then > IMHO the module loading code should just ignore it, pretend it wasn't there. > Similarly e.g. to how lto1 with -g0 should ignore debug statements that > could be in the LTO inputs. This required two changes. First, I had to teach lto-cgraph.c how to report an error rather then fail an assert when partitions are missing decls. Second, I taught the lto wrapper how to stream offloaded code on the absence of -fopen*. The only kink with this approach is that I had to build libgomp/openacc.f90 with -frandom-seed=1 to prevent lto related bootstrap failures. By the way, Thomas, I've added #pragma acc routine(__builtin_acc_on_device) seq to openacc.h. Is this OK, or should I just modify the various libgomp.oacc-c-c++-common/loop* tests to use that pragma directly? Or another option is to have the compiler add that attribute directly. I don't think we're really expecting the end user to use __builtin_acc_on_device directly since this is a gcc-ism. Cesar