0

Guys. I'm trying to speed up the loop using OpenMP.

If I speed up a loop that uses an integer variable, then everything works correctly:

  void main()
{
    //mpz_class i("0");
    //mpz_class k("1");
    //mpz_class l("1211728594799");
    int k = 9;
    int i = 0;
    int l = 1998899087;

#pragma omp parallel for
    for (i=k; i <= l; i++) {
        if (i == 1998899085)
            printf("kkk");
    }


    system("pause");


}

If I start using the MPIR variable in a loop, then I get errors when building the program in Visual Studio 2015. Here are the numbers of these errors: C3015, C3017,C3019. Here is the code that causes these errors:

    void main()
{
    mpz_class i("0");
    mpz_class k("1");
    mpz_class l("1211728594799");
    //int k = 9;
    //int i = 0;
    //int l = 1998899087;

#pragma omp parallel for
    for (i=k; i <= l; i++) {
        if (i == 1998899085)
            printf("kkk");
    }


    system("pause");


}

MPIR itself works correctly if I disable pragma omp parallel for then the code is going to be fine, but it works much slower than using int variable of the same range of numbers.

What should I do to make Open MP work correctly with MPIR and I could speed up my program by running it in parallel?

sdfpro
  • 1
  • 1
  • 2
    I expect that OpenMP objects to the use of iteration variables which are not of one of the intrinsic integral types. – High Performance Mark Oct 31 '17 at 13:28
  • For those of us without visual studio, it would be interesting if you post the actual error messages. They're likely to give us all good hints – Harald Nov 02 '17 at 08:49
  • Hi Harald. Error C3015 - invalid initialization in the For statement of the OpenMP directive. Error C3017 - Invalid type of completion check in the For statement of the OpenMP directive. Error C3019 -invalid increment in the For statement of the OpenMP directive. As far as I can tell, open mp can not work with gmp variables inside a loop. – sdfpro Nov 03 '17 at 14:23
  • Here is the information from MSDN: // C3015.cpp // compile with: / openmp int main () { int i = 0, j = 10; #pragma omp parallel { #pragma omp for for (; i <0; i + = j) // C3015 // Try the following line instead: // for (i = 0; i <0; i ++) --j; } } – sdfpro Nov 03 '17 at 14:24

0 Answers0