How can I parallel biginteger using openmp?

Lev Barenboim

I need to run some code from I: biginteger := 1 to some biginteger value in parallel. Since it's a biginteger I am not able to use parallel for and it seems like omp for does not work with a while loop.

Got a little problem with the code trying to improve it working mono.... Once I'm done fixing, I'll put an update in here explaining everything in details.

Michael Klemm

I can only comment on the OpenMP part of the question and it indeed you can only (directly) parallelize OpenMP loops that use regular integers (int, long, ...) as the type for the loop counter. This is for all OpenMP loop statements such as for, taskloop, etc.

One thing that you can always do is a pattern like this (assuming that the big integer is called bigint and has overloaded arithmetic operators). The following is just pseudo-code to show the idea, you'll have to adjust it to the actual API you want to use:

void process_bigint() {
    binint i;
    bigint start = some_start_value();
    binint end   = some_end_value();

    i = start;
    #pragma omp parallel
    #pragma omp single
    while(i < end) {
        #pragma omp task firstprivate(i)
        {
            process_bigint(i);
        }
    }
}

The main idea behind this is that you manually iterate through the space of big integer numbers that you want to process. This is done by one thread. For each number (or a bunch of number; pattern will be sightly more complex), you spawn an OpenMP task to do the actual work for the number.

How well this works depends a bit on what you will actually do for each of the number. If it's just a few operations, task creation might be too costly and you'd need to spawn a task for a group of numbers.

Hope that helps!

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

how can I get nth digit in a BigInteger?

分類Dev

How can I get an accurate length of a BigInteger?

分類Dev

How can I parallelize multiple for loop in OpenMP?

分類Dev

How can I parallel parsing in python?

分類Dev

How do I properly parallelise a for loop using OpenMP?

分類Dev

How can I avoid running some tests in parallel?

分類Dev

How can I use foreach function for parallel coding?

分類Dev

How can I illustatrate three parallel, non-consecutive, but dependent processes with BPMN?

分類Dev

How many parallel requests can be made using a single session token in a REST API

分類Dev

how can I save an attachment using exchangelib

分類Dev

How can I find and copy using gsutil?

分類Dev

How can I change # by code using interpolation

分類Dev

How can I generate XML using Haskell?

分類Dev

How can I start a process using cpulimit?

分類Dev

how can i print this using String Methods

分類Dev

How can I redirect a route using laravel?

分類Dev

How can I work with multiple values using ->?

分類Dev

How can I define a widget using javascript

分類Dev

How Can i Parse XML using Python

分類Dev

openmp parallel for collapse private variable outer loop

分類Dev

openmp parallel for collapse private variable outer loop

分類Dev

Is there a known limit to the number of CREATE TABLE I can run in parallel with Cassandra?

分類Dev

How can I get Record's details using Rtti?

分類Dev

How can I find application using hard drive?

分類Dev

How can I calibrate my printer using the LaTeX test page?

分類Dev

How can I upload media using go-twitter bot?

分類Dev

How can I upload a file to server, without browser, using go?

分類Dev

How can I check for errors in CRUD operations using GORM?

分類Dev

How can I connect to MongoDB Atlas using Robomongo?

Related 関連記事

  1. 1

    how can I get nth digit in a BigInteger?

  2. 2

    How can I get an accurate length of a BigInteger?

  3. 3

    How can I parallelize multiple for loop in OpenMP?

  4. 4

    How can I parallel parsing in python?

  5. 5

    How do I properly parallelise a for loop using OpenMP?

  6. 6

    How can I avoid running some tests in parallel?

  7. 7

    How can I use foreach function for parallel coding?

  8. 8

    How can I illustatrate three parallel, non-consecutive, but dependent processes with BPMN?

  9. 9

    How many parallel requests can be made using a single session token in a REST API

  10. 10

    how can I save an attachment using exchangelib

  11. 11

    How can I find and copy using gsutil?

  12. 12

    How can I change # by code using interpolation

  13. 13

    How can I generate XML using Haskell?

  14. 14

    How can I start a process using cpulimit?

  15. 15

    how can i print this using String Methods

  16. 16

    How can I redirect a route using laravel?

  17. 17

    How can I work with multiple values using ->?

  18. 18

    How can I define a widget using javascript

  19. 19

    How Can i Parse XML using Python

  20. 20

    openmp parallel for collapse private variable outer loop

  21. 21

    openmp parallel for collapse private variable outer loop

  22. 22

    Is there a known limit to the number of CREATE TABLE I can run in parallel with Cassandra?

  23. 23

    How can I get Record's details using Rtti?

  24. 24

    How can I find application using hard drive?

  25. 25

    How can I calibrate my printer using the LaTeX test page?

  26. 26

    How can I upload media using go-twitter bot?

  27. 27

    How can I upload a file to server, without browser, using go?

  28. 28

    How can I check for errors in CRUD operations using GORM?

  29. 29

    How can I connect to MongoDB Atlas using Robomongo?

ホットタグ

アーカイブ