Git Product home page Git Product logo

Comments (2)

matthiasdiener avatar matthiasdiener commented on June 11, 2024

omptest/HybridOMP.C

Lines 35 to 50 in 403e28d

for (int i=0; i<num_devices_visible; i++)
{
int A[1] = {-1};
#pragma omp target
{
A[0] = omp_is_initial_device();
}
if (A[0]==0)
num_gpus++;
else
printf("A[0]=%d\n",A[0]);
}
if (num_gpus == 0)
printf("HybridOMP: Able to use offloading: %s, #devices visible: %d #devices available: %d\n", num_gpus>0?"yes":"NO", num_devices_visible, num_gpus);
return num_gpus;

  • Let say you have N devices available. The loop just says that you offload the code N times, but you don't specify to which device to offload, so probably it will be offloaded always to the same device. Am I right?

Yes, you're right, the code is incorrect. Line 38 should be

#pragma omp target device(i)
  • Specification says that omp_is_initial_device() returns true (despite it is int) if the task is executed at a host device. You increment num_gpus if the function returns 0 (false), and then at line 49 you say that offloading is possible if the num_gpus > 0 .

I think this works as it should. If omp_is_initial_device() returns false, i.e. A[0]==0, we know the code was executed on a GPU, and num_gpus is incremented.

  • The condition at line 48 is the same as the condition at the following line, so there is a dead code.

I'm not exactly sure what you mean here, but line 48 should probably be removed, so that the status message is always printed.

I hope you get my point.

When executing your test application omp_is_initial_device() always returns 0. ldd confirms, that the binary is linked with the libraries from the GCC (GCC-10.2.0 or GCC-7.3.0 + CUDA/10.2.89) I have compiled (libstdc++.so, libgomp.so, libgcc_s.so). Do you have an idea could be wrong?

Not sure, maybe it is picking the wrong libraries (or library versions)? Maybe try checking with nvprof whether any code is executed on a device. Also, make sure you can run CUDA code correctly.

from omptest.

vysocky avatar vysocky commented on June 11, 2024

My problem was in misunderstanding the return value of the omp_is_initial_device(). The code works fine now, thanks!

from omptest.

Related Issues (1)

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.