From 415324b067d19244e3a49b9ede100e16c796fcb2 Mon Sep 17 00:00:00 2001 From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz> Date: Sun, 5 Mar 2023 21:44:41 +0100 Subject: [PATCH] =?UTF-8?q?algo/maxcut:=20Hacky=20na=20men=C5=A1=C3=AD=20p?= =?UTF-8?q?o=C4=8Det=20jader=20v=20juliov=C3=BDch=20knihovn=C3=A1ch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- algo/maxcut.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/algo/maxcut.cpp b/algo/maxcut.cpp index 09e3854eb..3c0903512 100644 --- a/algo/maxcut.cpp +++ b/algo/maxcut.cpp @@ -42,7 +42,10 @@ void calc_maxcut_naive(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)); fo(i, nd_size) @@ -50,10 +53,18 @@ void calc_maxcut_gw(Nd * nd, int nd_size) matrix[i][target-nd] += weight; 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;\ Random.seed!(3);\ - MaxCut.maxcut(["); + MaxCut.maxcut([", + thread_num, thread_num, thread_num); fo(i,nd_size) { fo(j, nd_size) fprintf(p_stdin, " %d", matrix[i][j]); -- GitLab