Background:
I have already written a program with julia. In order to pursue speed, I now want to solve this problem with parallel computing.
OpenMP C++:
I know that when I used C++ before, I used OpenMP to speed up my program. As far as I know, its use is very simple (because I don’t specialize in parallel computing, so it might look very simple):
#include <iostream>
#include <time.h>
void test()
{
int a = 0;
for (int i=0;i<100000000;i++)
a++;
}
int main()
{
clock_t t1 = clock();
for (int i=0;i<8;i++)
test();
clock_t t2 = clock();
std::cout<<"time: "<<t2-t1<<std::endl;
}
###############################################
# using OpenMP #
###############################################
#include <iostream>
#include <time.h>
void test()
{
int a = 0;
for (int i=0;i<100000000;i++)
a++;
}
int main()
{
clock_t t1 = clock();
#pragma omp parallel for
for (int i=0;i<8;i++)
test();
clock_t t2 = clock();
std::cout<<"time: "<<t2-t1<<std::endl;
}
Hope to get help:
I’ve seen the content of parallel computing in the Julia documentation, but I still don’t know how to solve the problem of parallel programs.
I want to know if Julia has the same method as OpenMP to speed up my program. I need to implement parallel computing in a short period of time(which means I need to make changes in the code not too complicated)). I don’t require it to have high performance, just like using OpenMP. The time saved is clearly related to the number of cores in the computer.
Do you have any good solutions (similar to the simple method of using OpenMP) or recommended reading materials, or have any suggestions for me, welcome everyone to comment in the comments, thank you! ![]()
Supplement:
1.
Julia Version 1.1.1
Commit 55e36cc308 (2019-05-16 04:10 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-3337U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, ivybridge)
NumberOfCores:2
NumberOfLogicalProcessors:4
############################################################
# I want to implement it on my own computer first, #
# then have a better performance workstation for #
# formal parallel work. #
############################################################
2.
I show the structure of the main part of my program:
module calculate
using LinearAlgebra
using DelimitedFiles
using DataFrames
include("area.jl")
include("volume.jl")
#My own formula for calculating area and volume)
export f
export g
...
function f(x1,x2,x3,x4)
for i = 1:n
v = volume(x1[n,1],x2[n,1],x3[n,1],x4[n,1])
area = area(x1[n,1],x2[n,1],x3[n,1])
end
return v
end
function g(...)
...(Structure is similar to f())
end
...
end
##########################################
# I will call this module later #
##########################################
3.
Currently I don’t want to involve parallel computing on GPUs, I just want to implement multicore parallel computing.