0

I want to understand if I can speed up the execution of a loop that works with the MPIR library using the GPU processor and c ++ amp for this?

Here is the code I would like to speed up:

#include <mpirxx.h>
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include <ctime>
#include <cstdio>
int main()
{
    srand(time(0));
    using namespace std;


    mpz_class i("0");
    mpz_class l("9999999999999999999999999999");

    for (i = 1; i <= l; i++)
    {
    }

    std::cout << "runtime =" << clock() / 1000.0 << std::endl;
    system("pause");
    return 0;

}

If I run the program on the CPU, it runs extremely slowly, I want to increase the speed of the program using the video card. As far as I understand, I can use almost any modern graphics card with DirectX 11 support, even embedded in the processor, for example intel HD Graphics 510

I think c ++ amp is the most suitable technology for implementing my task if it can interact with the MPIR library.

What should I change in the submitted code to run it on the GPU?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
sdfpro
  • 1
  • 1
  • [`using namespace std;` is a bad practice](https://stackoverflow.com/q/1452721/2176813), never use it. – tambre Oct 22 '17 at 13:40
  • @tambre In the general case yes, especially in the global scope. However having it inside a function somewhat mitigates the problems. Also, for a small example posted here it's usually okay IMO (as long as it's not in a header file). – Some programmer dude Oct 22 '17 at 13:42
  • How should I change the code to speed it up with c ++ amp, so that I can not lose the ability to work with the large numbers that the mpir library gives me (if I want to use a much larger number of passes in the loop than there is now)? – sdfpro Oct 22 '17 at 14:28
  • Using a bignum to count from 0 is useless, `long long` is already larger than you can hope to go through. – Marc Glisse Oct 22 '17 at 21:39

0 Answers0