Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build Clang/LLVM with OpenMP+ GPU support #103

Open
chunhualiao opened this issue Apr 13, 2020 · 4 comments
Open

build Clang/LLVM with OpenMP+ GPU support #103

chunhualiao opened this issue Apr 13, 2020 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@chunhualiao
Copy link
Owner

chunhualiao commented Apr 13, 2020

part of the process to revise the steps, ask the official steps.

https://hpc-wiki.info/hpc/Building_LLVM/Clang_with_OpenMP_Offloading_to_NVIDIA_GPUs

Later deployed in AWS gpu instance

@chunhualiao chunhualiao created this issue from a note in Metadirective implemention in Clang/LLVM (In progress) Apr 13, 2020
@chunhualiao
Copy link
Owner Author

chunhualiao commented Apr 14, 2020

//https://lc.llnl.gov/confluence/display/LC/Clang+OpenMP+4.5+with+GPU+support#space-menu-link-content
#include <stdio.h>
#include <omp.h>

int main()
{
  int runningOnGPU = 0;
  /* Test if GPU is available using OpenMP4.5 */
#pragma omp target map(from:runningOnGPU)
  {
    if (omp_is_initial_device() == 0)
      runningOnGPU = 1;
  }
  /* If still running on CPU, GPU must not be available */
  if (runningOnGPU)
    printf("### Able to use the GPU! ### \n");
  else
    printf("### Unable to use the GPU, using CPU! ###\n");

  return 0;
}

results

liao6@ip-128-115-246-7:~$ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda hasGPU.c
clang-10: warning: Unknown CUDA version 10.2. Assuming the latest supported version 10.1 [-Wunknown-cuda-version]
clang-10: warning: No library 'libomptarget-nvptx-sm_70.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices. [-Wopenmp-target]
liao6@ip-128-115-246-7:~$ ./a.out 
./a.out: error while loading shared libraries: libomp.so: cannot open shared object file: No such file or directory
liao6@ip-128-115-246-7:~$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/liao6/opt/llvm-10.0.0/lib
liao6@ip-128-115-246-7:~$ ./a.out 
### Unable to use the GPU, using CPU! ###

@chunhualiao
Copy link
Owner Author

No more warning about libomptarget lib. But the code still does not behave as expected.

//https://lc.llnl.gov/confluence/display/LC/Clang+OpenMP+4.5+with+GPU+support#space-menu-link-content
// Revised a bit
#include <stdio.h>
#include <omp.h>

int main()
{
  int runningOnGPU = 0;

  printf ("The number of target devices =%d\n", omp_get_num_devices());
  /* Test if GPU is available using OpenMP4.5 */
#pragma omp target map(from:runningOnGPU)
  {
    // This function returns true if currently running on the host device, false otherwise.
    if (!omp_is_initial_device())
      runningOnGPU = 1;
  }
  /* If still running on CPU, GPU must not be available */
  if (runningOnGPU == 1)
    printf("### Able to use the GPU! ### \n");
  else
    printf("### Unable to use the GPU, using CPU! ###\n");

  return 0;
}




liao6@ip-128-115-246-7:~$ clang -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda hasGPU.c
clang-10: warning: Unknown CUDA version 10.2. Assuming the latest supported version 10.1 [-Wunknown-cuda-version]

liao6@ip-128-115-246-7:~$ ./a.out 
The number of target devices =0
### Unable to use the GPU, using CPU! ###

@chunhualiao
Copy link
Owner Author

@ouankou Can you test the instructions on http://freecompilercamp.org/llvm-openmp-build/ using the GPU machine? I updated them a few weeks back and I need someone to review/test them.

@chunhualiao chunhualiao added the good first issue Good for newcomers label Jun 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Development

No branches or pull requests

2 participants