GithubHelp home page GithubHelp logo

jefflarkin / openacc-interoperability Goto Github PK

View Code? Open in Web Editor NEW
48.0 11.0 23.0 44 KB

Interoperability examples for OpenACC.

License: BSD 3-Clause "New" or "Revised" License

Makefile 21.42% C 39.95% Cuda 23.30% Fortran 9.66% C++ 5.68%
cuda fortran gpu openacc

openacc-interoperability's Introduction

Stupid OpenACC (Interoperability) Tricks

Author: Jeff Larkin [email protected]

This repository demonstrates interoperability between OpenACC and various other GPU programming models. An OpenACC-enabled compiler is required. The default makefile has been written for PGI and tested with PGI 20.9, although most if not all examples will work with earlier versions.

If building with the Cray Compiler Environment the makefile will detect this and adjust compiler flags and targets accordingly. Some targets rely on PGI CUDA Fortran features, these targets will be disabled when building with CCE.

Build Instructions:

$ make

Examples

  • cuda_main - calling OpenACC from CUDA C
  • openacc_c_main - Calling CUDA from OpenACC in C
  • openacc_c_cublas - Calling CUBLAS from OpenACC in C
  • thrust - Mixing OpenACC and Thrust in C++
  • cuda_map - Using OpenACC acc_map_data with CUDA in C
  • cuf_main - Calling OpenACC from CUDA Fortran
  • cuf_openacc_main - Calling CUDA Fortran from OpenACC
  • openacc_cublas - Calling CUBLAS from OpenACC in CUDA Fortran
  • acc_malloc - Same as cuda_main, but using the OpenACC API
  • openacc_streams - Mixes OpenACC async queues and CUDA streams
  • openacc_cuda_device - Calls a CUDA __device__ kernel within an OpenACC region

openacc-interoperability's People

Contributors

dorispnvidia avatar jefflarkin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openacc-interoperability's Issues

Error in make for openacc_c_main

I'm trying to compile openacc_c_main, but when make runs this command:
pgcc -o openacc_c_main -fast -acc -ta=nvidia:rdc -Minfo=accel saxpy_cuda.o openacc_c_main.o -Mcuda
I get this error:

saxpy_cuda.o: In function "saxpy":
tmpxft_000023f5_00000000-5_saxpy_cuda.cudafe1.cpp:(.text+0xef): undefined reference for "__cudaPushCallConfiguration"
saxpy_cuda.o: In function "__device_stub__Z12saxpy_kernelifPfS_(int, float, float*, float*)":
tmpxft_000023f5_00000000-5_saxpy_cuda.cudafe1.cpp:(.text+0x24b):  undefined reference for "__cudaPopCallConfiguration"
pgacclnk: child process exit status 1: /usr/bin/ld

Do you have any idea of what may be happening?

My pgcc and nvcc versions:

pgcc 17.10-0 64-bit target on x86-64 Linux -tp haswell 
Cuda compilation tools, release 9.2, V9.2.88

Interoperability with half-precision

Dear all,

thank you for these beautiful examples, really helpful!
My aplogies if this is not the right place to ask, feel free to close this issue.
I am not openning this issue cause I have a problem,
but rather, I am trying to do openacc-interoperability with cuda_fp16 half precision intrinsics.
I have looked both at openacc_c_main and openacc_cuda_device in order to get some influence.

My changes are here, for openacc_cuda_device: master...georgebisbas:wip_fp16

I am working on a V100 and I am using:

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Thu_Jun_11_22:26:38_PDT_2020
Cuda compilation tools, release 11.0, V11.0.194
Build cuda_11.0_bu.TC445_37.28540450_0

and

 pgcc --version

pgcc (aka nvc) 20.7-0 LLVM 64-bit target on x86-64 Linux -tp skylake 
PGI Compilers and Tools
Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.

Code compiles:

$ make openacc_cuda_device
nvc++ -fast -acc -Minfo=all -gpu= cc75 -c openacc_cuda_device.cpp
"openacc_cuda_device.cpp", line 19: warning: variable "tmp" was declared but
          never referenced
    float *x, *y, tmp;
                  ^

main:
     34, Generating copyout(y[:n]) [if not already present]
         Generating create(x[:n]) [if not already present]
     37, Loop is parallelizable
         Generating Tesla code
         37, #pragma acc loop gang, vector(128) /* blockIdx.x threadIdx.x */
     37, Complex loop carried dependence of x-> prevents parallelization
         Loop carried dependence of y-> prevents parallelization
         Loop not fused: complex flow graph
         Loop not vectorized: data dependency
         Generated vector simd code for the loop
         Loop unrolled 8 times
     45, Generating Tesla code
         45, #pragma acc loop gang, vector(128) /* blockIdx.x threadIdx.x */
     45, Loop not vectorized/parallelized: contains call
nvc++ -o openacc_cuda_device -fast -acc -Minfo=all -gpu= cc75 saxpy_cuda_device.o openacc_cuda_device.o -Mcuda 

but seems to be crashing when calling foo:

$ ./openacc_cuda_device 
c = 0.160000

I have been able so far to compile and execute with ease mixed precision code: https://github.com/NVIDIA-developer-blog/code-samples/tree/master/posts/mixed-precision
and bare openacc code as well as the openacc+cuda examples of this repository (
openacc-interoperability ).

Any inshight would be extremely helpful.
Regards,
--George

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.