Julia multiprocessing

Here is my python code for multiprocessing. How can I write this in 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

Please read

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/

3 Likes