Giter Site home page Giter Site logo

Comments (4)

rofirrim avatar rofirrim commented on July 22, 2024

Hi @Z10Frank,

I think in this case you can use #pragma oss task for as described here

https://pm.bsc.es/ftp/ompss-2/doc/spec/directives/index.html#task-for-clause

Let me know if this is useful.

Kind regards,

from mcxx.

Z10Frank avatar Z10Frank commented on July 22, 2024

Hello,
thank you for your answer, I know the #pragma oss task for construct, but my purpose was rather to understand the compatibility with OpenMP itself.

The objective is to progressively "taskify" a load imbalanced part of an existing code that already uses OpenMP, in particular with parallel regions, omp for, omp simd. So a preliminary question is if the use of OmpSs-2 in this code would imply the substitution of all existing OpenMP pragmas with "equivalents" in OmpSs-2. Or if there is a way to switch between OpenMP and OmpSs-2 pragmas with an if condition.

from mcxx.

rofirrim avatar rofirrim commented on July 22, 2024

The objective is to progressively "taskify" a load imbalanced part of an existing code that already uses OpenMP, in particular with parallel regions, omp for, omp simd. So a preliminary question is if the use of OmpSs-2 in this code would imply the substitution of all existing OpenMP pragmas with "equivalents" in OmpSs-2.

The OmpSs-2 compatibility with OpenMP is limited. It may happen that some constructs will require you to substitute/temporarily disable the unsupported OpenMP constructs.

Or if there is a way to switch between OpenMP and OmpSs-2 pragmas with an if condition.

Not sure what you mean by "if" condition here, one option is using the macro _OMPSS_2 so you can enable OpenMP or OmpSs-2 progressively in your code. This macro is enabled when you use --ompss-2 with Mercurium.

#if _OMPSS_2
#pragma oss task ...
#else 
#pragma omp ...
#endif

Hope this helps.

from mcxx.

Z10Frank avatar Z10Frank commented on July 22, 2024

Thank you!
To keep it in the archives, my test after the modifications:

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

using namespace std;

int main(int argc, char *argv[])
{
    #ifndef _OMPSS_2
    #pragma omp parallel
    #endif
    {

    #ifndef _OMPSS_2
    //with OpenMP
    #pragma omp for
    for (int i=0; i<10; i++)
    {
        #pragma omp critical
        cout<<"Hello omp for from thread "<<omp_get_thread_num()<<" iteration "<<i<<"\n"<<endl;
    }

    #else
    // with OmpSs-2
    for (int i=0; i<10; i++)
    {
        #pragma oss task firstprivate(i)
        {
        #pragma oss critical
        {
            cout<<"Hello OmpSs-2/, iteration "<<i<<endl;
        }
        }
    }
    #endif

    } // end parallel region if OpenMP is used
    return 0;

}

To compile with OpenMP:

mpiicpc -o test_OpenMP -fopenmp test_OpenMP_OmpSs-2.cpp

To compile with OmpSs-2:

I_MPI_CXX=mcxx MPICH_CXX=mcxx OMPI_CXX=mcxx mpiicpc -o test_OmpSs-2 --ompss-2 test_OpenMP_OmpSs-2.cpp 

from mcxx.

Related Issues (17)

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.