Skip to content
Snippets Groups Projects
Commit 415324b0 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

algo/maxcut: Hacky na menší počet jader v juliových knihovnách

parent 6ed2051e
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,10 @@ void calc_maxcut_naive(Nd * nd, int nd_size) ...@@ -42,7 +42,10 @@ void calc_maxcut_naive(Nd * nd, int nd_size)
void calc_maxcut_gw(Nd * nd, int nd_size) void calc_maxcut_gw(Nd * nd, int nd_size)
{ {
auto [p_stdin, p_stdout] = lib::dualpopen("julia"); int thread_num = 4;
char cmd[1000];
sprintf(cmd, "OMP_NUM_THREADS=%d julia -t %d", thread_num, thread_num);
auto [p_stdin, p_stdout] = lib::dualpopen(cmd);
{ {
vector<vector<int>> matrix(nd_size, vector<int>(nd_size, 0)); vector<vector<int>> matrix(nd_size, vector<int>(nd_size, 0));
fo(i, nd_size) fo(i, nd_size)
...@@ -50,10 +53,18 @@ void calc_maxcut_gw(Nd * nd, int nd_size) ...@@ -50,10 +53,18 @@ void calc_maxcut_gw(Nd * nd, int nd_size)
matrix[i][target-nd] += weight; matrix[i][target-nd] += weight;
fprintf(p_stdin, fprintf(p_stdin,
"include(\"MaxCut.jl/src/MaxCut.jl\");\ "import LinearAlgebra;\
import LinearAlgebra;\
LinearAlgebra.BLAS.set_num_threads(%d);\
import Convex;\
Convex.MOI.NumberOfThreads() = %d;\
import SCS;\
SCS.MOI.NumberOfThreads() = %d;\
include(\"MaxCut.jl/src/MaxCut.jl\");\
using Random;\ using Random;\
Random.seed!(3);\ Random.seed!(3);\
MaxCut.maxcut(["); MaxCut.maxcut([",
thread_num, thread_num, thread_num);
fo(i,nd_size) fo(i,nd_size)
{ {
fo(j, nd_size) fprintf(p_stdin, " %d", matrix[i][j]); fo(j, nd_size) fprintf(p_stdin, " %d", matrix[i][j]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment