# Julia multiprocessing

**URL:** <https://discourse.julialang.org/t/julia-multiprocessing/93150>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [January 18, 2023, 12:12pm UTC](https://discourse.julialang.org/t/julia-multiprocessing/93150 "2023-01-18T12:12:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sudipta\_Chakraborty](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sudipta_chakraborty/32/45860_2.png) [@Sudipta\_Chakraborty](https://discourse.julialang.org/u/Sudipta_Chakraborty)\
**Post date:** [January 18, 2023, 12:12pm UTC](https://discourse.julialang.org/t/julia-multiprocessing/93150/1 "2023-01-18T12:12:43Z")

</div>

Here is my python code for multiprocessing. How can I write this in Julia?

```julia
            if eris.NumProc > 1:
                global pair_check
                PL1, PL2 = mul_e_pairs(nocc)

                def pair_check(dummy):
                    i, j = dummy[0], dummy[1]
                    ttmp = np.einsum('kdt,cd ->ktc', eris.Lov.transpose(1, 2, 0), tau[i, j, :, :], optimize='greedy')
                    ttmp = np.einsum('ktc,tac->ka', ttmp, eris.Lvv, optimize='greedy')
                    temp = np.einsum('kb,ka->ab', -t1, ttmp, optimize='greedy')
                    ttmp = np.einsum('kct,cd->ktd', eris.Lov.transpose(1, 2, 0), tau[i, j, :, :], optimize='greedy')
                    ttmp = np.einsum('ktd,tbd->kb', ttmp, eris.Lvv, optimize='greedy')
                    temp -= np.einsum('ka,kb->ab', t1, ttmp, optimize='greedy')
                    ttmp = np.einsum('tac,cd->tad', eris.Lvv, tau[i, j, :, :], optimize='greedy')
                    temp += np.einsum('tad,tbd->ab', ttmp, eris.Lvv, optimize='greedy')
                    return temp

                with Pool(eris.NumProc) as p:
                    t21_temp = p.map(pair_check, PL1)
                    t21_temp2 = p.map(pair_check, PL2)

                m = 0
                for (i, j) in PL1:
                    t2new[i, j, :, :] += t21_temp[m]
                    m += 1

                m = 0
                for (i, j) in PL2:
                    t2new[i, j, :, :] += t21_temp2[m]
                    t2new[j, i, :, :] += t21_temp2[m].T
                    m += 1

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [January 18, 2023, 12:33pm UTC](https://discourse.julialang.org/t/julia-multiprocessing/93150/2 "2023-01-18T12:33:32Z")

</div>

Please read

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

I don’t think you’ll get much useful feedback for the question the way it’s written now, mostly because it’s very hard to say anything other beyond here’s an overview of the parallelism approaches supported by Julia:

[https://docs.julialang.org/en/v1/manual/parallel-computing/](https://docs.julialang.org/en/v1/manual/parallel-computing/)
