[llvm-bugs] [Bug 49874] New: USM not working

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 6 22:06:54 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=49874

            Bug ID: 49874
           Summary: USM not working
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: itaru.kitayama at gmail.com
                CC: llvm-bugs at lists.llvm.org

```
#include <iostream>
#include <omp.h>

//#pragma omp requires unified_shared_memory
#define N 1024

void func(int p[N]) {
  std::cout << p << std::endl;
  std::cout << &p << std::endl;

#pragma omp target
  {
    for (int i = 0; i < N; i++) {
      p[0] = 123456;
    }
  }
  std::cout << p[0] << std::endl;
}

int main() {

  int a[N] = {0};
  std::cout << a << std::endl;
  std::cout << &a << std::endl;

#pragma omp target
  {
    for (int i = 0; i < N; i++) {
      a[0] = 123456;
    }
  }
  std::cout << a[0] << std::endl;

  func(a);

  int *b = new int[N];
  std::cout << b << std::endl;
  std::cout << &b << std::endl;

#pragma omp target
  {
    for (int i = 0; i < N; i++) {
      b[0] = 123456;
    }
  }
  std::cout << b[0] << std::endl;

  func(b);

  return 0;

}
```

The above test code in C++ fails at runtime on an A100 target.
The Linux kernel is enabled HMM, which is necessary for USM to work.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210407/c48ef03c/attachment-0001.html>


More information about the llvm-bugs mailing list