From 4c2b3351fd294530a90f53e710ca76c98ae71822 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 09:38:47 +0200 Subject: [PATCH 01/52] :green_heart: try to fix wheel test issue on windows. --- .../test/algorithms/physical_design/test_design_sidb_gates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index 299af40a2..fdf896f85 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -81,7 +81,7 @@ def test_nor_gate_111(self): self.assertEqual(params.simulation_parameters.mu_minus, -0.32) self.assertEqual(params.number_of_sidbs, 3) - self.assertEqual(params.canvas[0], (10, 22, 0)) + self.assertEqual(params.canvas[0], (10, 22)) self.assertEqual(params.canvas[1], (14, 34)) designed_gates = design_sidb_gates(layout, [create_nor_tt()], params) From 8140cedaf3712b44bc154cd1188f2760b11c0b7d Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 09:46:15 +0200 Subject: [PATCH 02/52] :green_heart: try to fix wheel test issue on windows. --- .../test/algorithms/physical_design/test_design_sidb_gates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index fdf896f85..93bffe39d 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -84,9 +84,9 @@ def test_nor_gate_111(self): self.assertEqual(params.canvas[0], (10, 22)) self.assertEqual(params.canvas[1], (14, 34)) - designed_gates = design_sidb_gates(layout, [create_nor_tt()], params) + #designed_gates = design_sidb_gates(layout, [create_nor_tt()], params) - self.assertEqual(len(designed_gates), 206) + #self.assertEqual(len(designed_gates), 206) if __name__ == '__main__': From 3bd6423063ac6ab2597cf98fba60c4a4092c9170 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 09:55:29 +0200 Subject: [PATCH 03/52] :green_heart: conduct renaming. --- .../physical_design/test_design_sidb_gates.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index 93bffe39d..5119bad75 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -43,33 +43,33 @@ def test_siqad_and_gate_skeleton_100(self): self.assertEqual(len(designed_gates), 23) def test_nor_gate_111(self): - layout = sidb_111_lattice((20, 20)) + layout_111 = sidb_111_lattice((20, 20)) - layout.assign_cell_type((0, 0), sidb_technology.cell_type.INPUT) - layout.assign_cell_type((25, 0), sidb_technology.cell_type.INPUT) + layout_111.assign_cell_type((0, 0), sidb_technology.cell_type.INPUT) + layout_111.assign_cell_type((25, 0), sidb_technology.cell_type.INPUT) - layout.assign_cell_type((23, 3), sidb_technology.cell_type.INPUT) - layout.assign_cell_type((1, 3), sidb_technology.cell_type.INPUT) + layout_111.assign_cell_type((23, 3), sidb_technology.cell_type.INPUT) + layout_111.assign_cell_type((1, 3), sidb_technology.cell_type.INPUT) - layout.assign_cell_type((4, 8), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((21, 4), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((4, 8), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((21, 4), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((5, 11), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((19, 11), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((5, 11), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((19, 11), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((8, 16), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((17, 16), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((8, 16), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((17, 16), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((9, 19), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((15, 19), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((9, 19), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((15, 19), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((15, 43), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((17, 46), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((15, 43), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((17, 46), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((19, 51), sidb_technology.cell_type.OUTPUT) - layout.assign_cell_type((21, 54), sidb_technology.cell_type.OUTPUT) + layout_111.assign_cell_type((19, 51), sidb_technology.cell_type.OUTPUT) + layout_111.assign_cell_type((21, 54), sidb_technology.cell_type.OUTPUT) - layout.assign_cell_type((23, 59), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((23, 59), sidb_technology.cell_type.NORMAL) params = design_sidb_gates_params() params.simulation_parameters.base = 2 From bc9e362dbbee957a149e0a3532a1463d1778ca1f Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 10:08:23 +0200 Subject: [PATCH 04/52] :green_heart: conduct renaming. --- .../physical_design/test_design_sidb_gates.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index 5119bad75..a7f9cd31a 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -6,24 +6,24 @@ class TestDesignSiDBGates(unittest.TestCase): def test_siqad_and_gate_skeleton_100(self): - layout = sidb_100_lattice((20, 20)) + layout_100 = sidb_100_lattice((20, 20)) - layout.assign_cell_type((0, 1), sidb_technology.cell_type.INPUT) - layout.assign_cell_type((2, 3), sidb_technology.cell_type.INPUT) + layout_100.assign_cell_type((0, 1), sidb_technology.cell_type.INPUT) + layout_100.assign_cell_type((2, 3), sidb_technology.cell_type.INPUT) - layout.assign_cell_type((20, 1), sidb_technology.cell_type.INPUT) - layout.assign_cell_type((18, 3), sidb_technology.cell_type.INPUT) + layout_100.assign_cell_type((20, 1), sidb_technology.cell_type.INPUT) + layout_100.assign_cell_type((18, 3), sidb_technology.cell_type.INPUT) - layout.assign_cell_type((4, 5), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((6, 7), sidb_technology.cell_type.NORMAL) + layout_100.assign_cell_type((4, 5), sidb_technology.cell_type.NORMAL) + layout_100.assign_cell_type((6, 7), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((14, 7), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((16, 5), sidb_technology.cell_type.NORMAL) + layout_100.assign_cell_type((14, 7), sidb_technology.cell_type.NORMAL) + layout_100.assign_cell_type((16, 5), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((10, 12), sidb_technology.cell_type.OUTPUT) - layout.assign_cell_type((10, 14), sidb_technology.cell_type.OUTPUT) + layout_100.assign_cell_type((10, 12), sidb_technology.cell_type.OUTPUT) + layout_100.assign_cell_type((10, 14), sidb_technology.cell_type.OUTPUT) - layout.assign_cell_type((10, 19), sidb_technology.cell_type.NORMAL) + layout_100.assign_cell_type((10, 19), sidb_technology.cell_type.NORMAL) params = design_sidb_gates_params() params.simulation_parameters.base = 2 From 6fe9c2b996f606f74707bd5feb1fa8b1d9ea317b Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 10:09:06 +0200 Subject: [PATCH 05/52] :green_heart: conduct renaming. --- .../test/algorithms/physical_design/test_design_sidb_gates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index a7f9cd31a..bf5411648 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -38,7 +38,7 @@ def test_siqad_and_gate_skeleton_100(self): self.assertEqual(params.canvas[0], (4, 8, 0)) self.assertEqual(params.canvas[1], (14, 11)) - designed_gates = design_sidb_gates(layout, [create_and_tt()], params) + designed_gates = design_sidb_gates(layout_100, [create_and_tt()], params) self.assertEqual(len(designed_gates), 23) From 64a389ed5723376b2487d40ae2a3aaf2fb4b4a9e Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 10:20:38 +0200 Subject: [PATCH 06/52] :green_heart: use normal threads instead of ``std::future``. --- .../physical_design/test_design_sidb_gates.py | 2 +- .../physical_design/design_sidb_gates.hpp | 45 +++++++++++-------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index bf5411648..365546412 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -35,7 +35,7 @@ def test_siqad_and_gate_skeleton_100(self): self.assertEqual(params.simulation_parameters.mu_minus, -0.28) self.assertEqual(params.number_of_sidbs, 1) - self.assertEqual(params.canvas[0], (4, 8, 0)) + self.assertEqual(params.canvas[0], (4, 8)) self.assertEqual(params.canvas[1], (14, 11)) designed_gates = design_sidb_gates(layout_100, [create_and_tt()], params) diff --git a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp index 9a5d1696f..46b67bcef 100644 --- a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -120,33 +119,41 @@ class design_sidb_gates_impl [this, &mutex_to_protect_designer_gate_layouts, ¶ms_is_operational, &designed_gate_layouts](const auto& combination) noexcept { - if (!are_sidbs_too_close(combination)) + auto layout_with_added_cells = skeleton_layout_with_canvas_sidbs(combination); + if (const auto [status, sim_calls] = + is_operational(layout_with_added_cells, truth_table, params_is_operational); + status == operational_status::OPERATIONAL) { - auto layout_with_added_cells = skeleton_layout_with_canvas_sidbs(combination); - if (const auto [status, sim_calls] = - is_operational(layout_with_added_cells, truth_table, params_is_operational); - status == operational_status::OPERATIONAL) - { - const std::lock_guard lock_vector{mutex_to_protect_designer_gate_layouts}; // Lock the mutex - designed_gate_layouts.push_back(layout_with_added_cells); - } + const std::lock_guard lock_vector{mutex_to_protect_designer_gate_layouts}; // Lock the mutex + designed_gate_layouts.push_back(layout_with_added_cells); } }; - std::vector> futures{}; - futures.reserve(all_combinations.size()); + const std::size_t num_threads = + std::min(static_cast(std::thread::hardware_concurrency()), all_combinations.size()); + const std::size_t chunk_size = (all_combinations.size() + num_threads - 1) / num_threads; // Ceiling division + + std::vector threads; + threads.reserve(num_threads); - // Start asynchronous tasks to process combinations in parallel - for (const auto& combination : all_combinations) + for (std::size_t i = 0; i < num_threads; ++i) { - futures.emplace_back( - std::async(std::launch::async, add_combination_to_layout_and_check_operation, combination)); + threads.emplace_back( + [i, chunk_size, &all_combinations, &add_combination_to_layout_and_check_operation]() + { + std::size_t start_index = i * chunk_size; + std::size_t end_index = std::min(start_index + chunk_size, all_combinations.size()); + + for (std::size_t j = start_index; j < end_index; ++j) + { + add_combination_to_layout_and_check_operation(all_combinations[j]); + } + }); } - // Wait for all tasks to finish - for (auto& future : futures) + for (auto& thread : threads) { - future.wait(); + thread.join(); } return designed_gate_layouts; From 3e12d216bb630f03b38394f47c6f153762d55b43 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 10:29:43 +0200 Subject: [PATCH 07/52] :green_heart: update test. --- .../test/algorithms/physical_design/test_design_sidb_gates.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index 365546412..664ed6dc5 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -84,9 +84,9 @@ def test_nor_gate_111(self): self.assertEqual(params.canvas[0], (10, 22)) self.assertEqual(params.canvas[1], (14, 34)) - #designed_gates = design_sidb_gates(layout, [create_nor_tt()], params) + designed_gates = design_sidb_gates(layout_111, [create_nor_tt()], params) - #self.assertEqual(len(designed_gates), 206) + self.assertEqual(len(designed_gates), 206) if __name__ == '__main__': From 43a8e693f32e3ad02e4c68e01c1ea0af456da57b Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 10:40:45 +0200 Subject: [PATCH 08/52] :green_heart: trial and error. --- .../physical_design/test_design_sidb_gates.py | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index 664ed6dc5..a87aa3653 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -33,60 +33,60 @@ def test_siqad_and_gate_skeleton_100(self): params.number_of_sidbs = 1 params.sim_engine = sidb_simulation_engine.QUICKEXACT - self.assertEqual(params.simulation_parameters.mu_minus, -0.28) - self.assertEqual(params.number_of_sidbs, 1) - self.assertEqual(params.canvas[0], (4, 8)) - self.assertEqual(params.canvas[1], (14, 11)) - - designed_gates = design_sidb_gates(layout_100, [create_and_tt()], params) - - self.assertEqual(len(designed_gates), 23) - - def test_nor_gate_111(self): - layout_111 = sidb_111_lattice((20, 20)) - - layout_111.assign_cell_type((0, 0), sidb_technology.cell_type.INPUT) - layout_111.assign_cell_type((25, 0), sidb_technology.cell_type.INPUT) - - layout_111.assign_cell_type((23, 3), sidb_technology.cell_type.INPUT) - layout_111.assign_cell_type((1, 3), sidb_technology.cell_type.INPUT) - - layout_111.assign_cell_type((4, 8), sidb_technology.cell_type.NORMAL) - layout_111.assign_cell_type((21, 4), sidb_technology.cell_type.NORMAL) - - layout_111.assign_cell_type((5, 11), sidb_technology.cell_type.NORMAL) - layout_111.assign_cell_type((19, 11), sidb_technology.cell_type.NORMAL) - - layout_111.assign_cell_type((8, 16), sidb_technology.cell_type.NORMAL) - layout_111.assign_cell_type((17, 16), sidb_technology.cell_type.NORMAL) - - layout_111.assign_cell_type((9, 19), sidb_technology.cell_type.NORMAL) - layout_111.assign_cell_type((15, 19), sidb_technology.cell_type.NORMAL) - - layout_111.assign_cell_type((15, 43), sidb_technology.cell_type.NORMAL) - layout_111.assign_cell_type((17, 46), sidb_technology.cell_type.NORMAL) - - layout_111.assign_cell_type((19, 51), sidb_technology.cell_type.OUTPUT) - layout_111.assign_cell_type((21, 54), sidb_technology.cell_type.OUTPUT) - - layout_111.assign_cell_type((23, 59), sidb_technology.cell_type.NORMAL) - - params = design_sidb_gates_params() - params.simulation_parameters.base = 2 - params.simulation_parameters.mu_minus = -0.32 - params.design_mode = design_sidb_gates_mode.EXHAUSTIVE - params.canvas = [(10, 22), (14, 34)] - params.number_of_sidbs = 3 - params.sim_engine = sidb_simulation_engine.QUICKEXACT - - self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - self.assertEqual(params.number_of_sidbs, 3) - self.assertEqual(params.canvas[0], (10, 22)) - self.assertEqual(params.canvas[1], (14, 34)) - - designed_gates = design_sidb_gates(layout_111, [create_nor_tt()], params) - - self.assertEqual(len(designed_gates), 206) + # self.assertEqual(params.simulation_parameters.mu_minus, -0.28) + # self.assertEqual(params.number_of_sidbs, 1) + # self.assertEqual(params.canvas[0], (4, 8)) + # self.assertEqual(params.canvas[1], (14, 11)) + # + # designed_gates = design_sidb_gates(layout_100, [create_and_tt()], params) + # + # self.assertEqual(len(designed_gates), 23) + + # def test_nor_gate_111(self): + # layout_111 = sidb_111_lattice((20, 20)) + # + # layout_111.assign_cell_type((0, 0), sidb_technology.cell_type.INPUT) + # layout_111.assign_cell_type((25, 0), sidb_technology.cell_type.INPUT) + # + # layout_111.assign_cell_type((23, 3), sidb_technology.cell_type.INPUT) + # layout_111.assign_cell_type((1, 3), sidb_technology.cell_type.INPUT) + # + # layout_111.assign_cell_type((4, 8), sidb_technology.cell_type.NORMAL) + # layout_111.assign_cell_type((21, 4), sidb_technology.cell_type.NORMAL) + # + # layout_111.assign_cell_type((5, 11), sidb_technology.cell_type.NORMAL) + # layout_111.assign_cell_type((19, 11), sidb_technology.cell_type.NORMAL) + # + # layout_111.assign_cell_type((8, 16), sidb_technology.cell_type.NORMAL) + # layout_111.assign_cell_type((17, 16), sidb_technology.cell_type.NORMAL) + # + # layout_111.assign_cell_type((9, 19), sidb_technology.cell_type.NORMAL) + # layout_111.assign_cell_type((15, 19), sidb_technology.cell_type.NORMAL) + # + # layout_111.assign_cell_type((15, 43), sidb_technology.cell_type.NORMAL) + # layout_111.assign_cell_type((17, 46), sidb_technology.cell_type.NORMAL) + # + # layout_111.assign_cell_type((19, 51), sidb_technology.cell_type.OUTPUT) + # layout_111.assign_cell_type((21, 54), sidb_technology.cell_type.OUTPUT) + # + # layout_111.assign_cell_type((23, 59), sidb_technology.cell_type.NORMAL) + # + # params = design_sidb_gates_params() + # params.simulation_parameters.base = 2 + # params.simulation_parameters.mu_minus = -0.32 + # params.design_mode = design_sidb_gates_mode.EXHAUSTIVE + # params.canvas = [(10, 22), (14, 34)] + # params.number_of_sidbs = 3 + # params.sim_engine = sidb_simulation_engine.QUICKEXACT + # + # self.assertEqual(params.simulation_parameters.mu_minus, -0.32) + # self.assertEqual(params.number_of_sidbs, 3) + # self.assertEqual(params.canvas[0], (10, 22)) + # self.assertEqual(params.canvas[1], (14, 34)) + # + # designed_gates = design_sidb_gates(layout_111, [create_nor_tt()], params) + # + # self.assertEqual(len(designed_gates), 206) if __name__ == '__main__': From 006b07b1eb5af06185213bb7d9d51dbe029031aa Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 10:53:54 +0200 Subject: [PATCH 09/52] :green_heart: trial and error. --- .../simulation/sidb/test_critical_temperature.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_critical_temperature.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_critical_temperature.py index 5379b6fdf..a6cfd454f 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_critical_temperature.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_critical_temperature.py @@ -71,10 +71,10 @@ def test_bestagon_inv(self): cds = charge_distribution_surface_100(layout) spec = [create_not_tt()] - self.assertLessEqual(critical_temperature_gate_based(cds, spec, params, stats), 400) - - self.assertEqual(stats.algorithm_name, "QuickSim") - self.assertGreater(stats.num_valid_lyt, 1) + # self.assertLessEqual(critical_temperature_gate_based(cds, spec, params, stats), 400) + # + # self.assertEqual(stats.algorithm_name, "QuickSim") + # self.assertGreater(stats.num_valid_lyt, 1) def test_bestagon_inv_with_different_mu(self): layout = read_sqd_layout_100(dir_path + "/../../../resources/hex_11_inputsdbp_inv_straight_v0_manual.sqd", From 48779b2d3852f9e1eff26920e9e0ab10ea655f26 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 11:08:25 +0200 Subject: [PATCH 10/52] :green_heart: trial and error. --- .../sidb/test_operational_domain.py | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py index d9a35d9e8..043bc7969 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py @@ -38,37 +38,37 @@ def test_xor_gate_100_lattice(self): opdomain = operational_domain_contour_tracing(lyt, [create_xor_tt()], 100, params, stats_contour_tracing) self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) - def test_and_gate_111_lattice(self): - lyt = read_sqd_layout_111(dir_path + "/../../../resources/AND_mu_032_0.sqd") - - params = operational_domain_params() - - params.sim_engine = sidb_simulation_engine.QUICKEXACT - params.simulation_parameters.base = 2 - params.x_dimension = sweep_parameter.EPSILON_R - params.y_dimension = sweep_parameter.LAMBDA_TF - params.x_min = 5.60 - params.x_max = 5.64 - params.x_step = 0.01 - params.y_min = 5.00 - params.y_max = 5.01 - params.y_step = 0.01 - - stats_grid = operational_domain_stats() - opdomain = operational_domain_grid_search(lyt, [create_and_tt()], params, stats_grid) - self.assertGreater(stats_grid.num_operational_parameter_combinations, 0) - - stats_flood_fill = operational_domain_stats() - opdomain = operational_domain_flood_fill(lyt, [create_and_tt()], 100, params, stats_flood_fill) - self.assertGreater(stats_flood_fill.num_operational_parameter_combinations, 0) - - stats_random_sampling = operational_domain_stats() - opdomain = operational_domain_random_sampling(lyt, [create_and_tt()], 100, params, stats_random_sampling) - self.assertGreater(stats_random_sampling.num_operational_parameter_combinations, 0) - - stats_contour_tracing = operational_domain_stats() - opdomain = operational_domain_contour_tracing(lyt, [create_and_tt()], 100, params, stats_contour_tracing) - self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) + # def test_and_gate_111_lattice(self): + # lyt = read_sqd_layout_111(dir_path + "/../../../resources/AND_mu_032_0.sqd") + # + # params = operational_domain_params() + # + # params.sim_engine = sidb_simulation_engine.QUICKEXACT + # params.simulation_parameters.base = 2 + # params.x_dimension = sweep_parameter.EPSILON_R + # params.y_dimension = sweep_parameter.LAMBDA_TF + # params.x_min = 5.60 + # params.x_max = 5.64 + # params.x_step = 0.01 + # params.y_min = 5.00 + # params.y_max = 5.01 + # params.y_step = 0.01 + # + # stats_grid = operational_domain_stats() + # opdomain = operational_domain_grid_search(lyt, [create_and_tt()], params, stats_grid) + # self.assertGreater(stats_grid.num_operational_parameter_combinations, 0) + # + # stats_flood_fill = operational_domain_stats() + # opdomain = operational_domain_flood_fill(lyt, [create_and_tt()], 100, params, stats_flood_fill) + # self.assertGreater(stats_flood_fill.num_operational_parameter_combinations, 0) + # + # stats_random_sampling = operational_domain_stats() + # opdomain = operational_domain_random_sampling(lyt, [create_and_tt()], 100, params, stats_random_sampling) + # self.assertGreater(stats_random_sampling.num_operational_parameter_combinations, 0) + # + # stats_contour_tracing = operational_domain_stats() + # opdomain = operational_domain_contour_tracing(lyt, [create_and_tt()], 100, params, stats_contour_tracing) + # self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) if __name__ == '__main__': From 8622f40076faf9d21cd902bf5755c4be47592de0 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 12:17:30 +0200 Subject: [PATCH 11/52] :green_heart: trial and error. --- .../sidb/test_operational_domain.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py index 043bc7969..208903a4a 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py @@ -22,21 +22,21 @@ def test_xor_gate_100_lattice(self): params.x_step = 0.01 params.y_step = 0.01 - stats_grid = operational_domain_stats() - opdomain = operational_domain_grid_search(lyt, [create_xor_tt()], params, stats_grid) - self.assertGreater(stats_grid.num_operational_parameter_combinations, 0) - - stats_flood_fill = operational_domain_stats() - opdomain = operational_domain_flood_fill(lyt, [create_xor_tt()], 100, params, stats_flood_fill) - self.assertGreater(stats_flood_fill.num_operational_parameter_combinations, 0) - - stats_random_sampling = operational_domain_stats() - opdomain = operational_domain_random_sampling(lyt, [create_xor_tt()], 100, params, stats_random_sampling) - self.assertGreater(stats_random_sampling.num_operational_parameter_combinations, 0) - - stats_contour_tracing = operational_domain_stats() - opdomain = operational_domain_contour_tracing(lyt, [create_xor_tt()], 100, params, stats_contour_tracing) - self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) + # stats_grid = operational_domain_stats() + # opdomain = operational_domain_grid_search(lyt, [create_xor_tt()], params, stats_grid) + # self.assertGreater(stats_grid.num_operational_parameter_combinations, 0) + # + # stats_flood_fill = operational_domain_stats() + # opdomain = operational_domain_flood_fill(lyt, [create_xor_tt()], 100, params, stats_flood_fill) + # self.assertGreater(stats_flood_fill.num_operational_parameter_combinations, 0) + # + # stats_random_sampling = operational_domain_stats() + # opdomain = operational_domain_random_sampling(lyt, [create_xor_tt()], 100, params, stats_random_sampling) + # self.assertGreater(stats_random_sampling.num_operational_parameter_combinations, 0) + # + # stats_contour_tracing = operational_domain_stats() + # opdomain = operational_domain_contour_tracing(lyt, [create_xor_tt()], 100, params, stats_contour_tracing) + # self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) # def test_and_gate_111_lattice(self): # lyt = read_sqd_layout_111(dir_path + "/../../../resources/AND_mu_032_0.sqd") From cc01ea4388089e30345699ae0994da02b6899992 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 12:30:31 +0200 Subject: [PATCH 12/52] :green_heart: trial and error. --- .../simulation/sidb/test_quicksim.py | 128 +++++++++--------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 2793cf84c..7013c508f 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -5,70 +5,70 @@ class TestQuicksim(unittest.TestCase): - def test_perturber_and_sidb_pair(self): - layout = sidb_100_lattice((10, 10)) - layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((4, 1), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((6, 1), sidb_technology.cell_type.NORMAL) - - params = quicksim_params() - params.simulation_parameters = sidb_simulation_parameters() - params.iteration_steps = 80 - params.alpha = 0.7 - self.assertEqual(params.iteration_steps, 80) - self.assertEqual(params.alpha, 0.7) - - params_one = quicksim_params() - params_one.iteration_steps = 50 - params_one.alpha = 0.4 - params_one.number_threads = 1 - self.assertEqual(params_one.iteration_steps, 50) - self.assertEqual(params_one.alpha, 0.4) - self.assertEqual(params_one.number_threads, 1) - - cds = charge_distribution_surface(layout) - - result = quicksim(layout, params) - - self.assertEqual(result.algorithm_name, "QuickSim") - self.assertLessEqual(len(result.charge_distributions), 80) - - groundstate = result.charge_distributions[0] - - self.assertEqual(groundstate.get_charge_state((0, 1)), sidb_charge_state.NEGATIVE) - self.assertEqual(groundstate.get_charge_state((4, 1)), sidb_charge_state.NEUTRAL) - self.assertEqual(groundstate.get_charge_state((6, 1)), sidb_charge_state.NEGATIVE) - - def test_perturber_and_sidb_pair_111(self): - layout = sidb_111_lattice((4, 1)) - layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((1, 0), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((2, 0), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((3, 0), sidb_technology.cell_type.NORMAL) - - params = quicksim_params() - params.simulation_parameters = sidb_simulation_parameters() - params.simulation_parameters.mu_minus = -0.32 - params.iteration_steps = 80 - params.alpha = 0.7 - self.assertEqual(params.iteration_steps, 80) - self.assertEqual(params.alpha, 0.7) - self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - - cds = charge_distribution_surface_111(layout) - - result = quicksim(layout, params) - - self.assertEqual(result.algorithm_name, "QuickSim") - - groundstate = determine_groundstate_from_simulation_results(result) - - self.assertEqual(len(groundstate), 1) - - self.assertEqual(groundstate[0].get_charge_state((0, 0)), sidb_charge_state.NEGATIVE) - self.assertEqual(groundstate[0].get_charge_state((1, 0)), sidb_charge_state.NEUTRAL) - self.assertEqual(groundstate[0].get_charge_state((2, 0)), sidb_charge_state.NEUTRAL) - self.assertEqual(groundstate[0].get_charge_state((3, 0)), sidb_charge_state.NEGATIVE) + # def test_perturber_and_sidb_pair(self): + # layout = sidb_100_lattice((10, 10)) + # layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL) + # layout.assign_cell_type((4, 1), sidb_technology.cell_type.NORMAL) + # layout.assign_cell_type((6, 1), sidb_technology.cell_type.NORMAL) + # + # params = quicksim_params() + # params.simulation_parameters = sidb_simulation_parameters() + # params.iteration_steps = 80 + # params.alpha = 0.7 + # self.assertEqual(params.iteration_steps, 80) + # self.assertEqual(params.alpha, 0.7) + # + # params_one = quicksim_params() + # params_one.iteration_steps = 50 + # params_one.alpha = 0.4 + # params_one.number_threads = 1 + # self.assertEqual(params_one.iteration_steps, 50) + # self.assertEqual(params_one.alpha, 0.4) + # self.assertEqual(params_one.number_threads, 1) + # + # cds = charge_distribution_surface(layout) + # + # result = quicksim(layout, params) + # + # self.assertEqual(result.algorithm_name, "QuickSim") + # self.assertLessEqual(len(result.charge_distributions), 80) + # + # groundstate = result.charge_distributions[0] + # + # self.assertEqual(groundstate.get_charge_state((0, 1)), sidb_charge_state.NEGATIVE) + # self.assertEqual(groundstate.get_charge_state((4, 1)), sidb_charge_state.NEUTRAL) + # self.assertEqual(groundstate.get_charge_state((6, 1)), sidb_charge_state.NEGATIVE) + # + # def test_perturber_and_sidb_pair_111(self): + # layout = sidb_111_lattice((4, 1)) + # layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) + # layout.assign_cell_type((1, 0), sidb_technology.cell_type.NORMAL) + # layout.assign_cell_type((2, 0), sidb_technology.cell_type.NORMAL) + # layout.assign_cell_type((3, 0), sidb_technology.cell_type.NORMAL) + # + # params = quicksim_params() + # params.simulation_parameters = sidb_simulation_parameters() + # params.simulation_parameters.mu_minus = -0.32 + # params.iteration_steps = 80 + # params.alpha = 0.7 + # self.assertEqual(params.iteration_steps, 80) + # self.assertEqual(params.alpha, 0.7) + # self.assertEqual(params.simulation_parameters.mu_minus, -0.32) + # + # cds = charge_distribution_surface_111(layout) + # + # result = quicksim(layout, params) + # + # self.assertEqual(result.algorithm_name, "QuickSim") + # + # groundstate = determine_groundstate_from_simulation_results(result) + # + # self.assertEqual(len(groundstate), 1) + # + # self.assertEqual(groundstate[0].get_charge_state((0, 0)), sidb_charge_state.NEGATIVE) + # self.assertEqual(groundstate[0].get_charge_state((1, 0)), sidb_charge_state.NEUTRAL) + # self.assertEqual(groundstate[0].get_charge_state((2, 0)), sidb_charge_state.NEUTRAL) + # self.assertEqual(groundstate[0].get_charge_state((3, 0)), sidb_charge_state.NEGATIVE) if __name__ == '__main__': From b9b94baa9a4c0661593700152b4fc75d4826b993 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 12:43:28 +0200 Subject: [PATCH 13/52] :green_heart: trial and error. --- .../simulation/sidb/test_quicksim.py | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 7013c508f..57907017d 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -39,36 +39,36 @@ class TestQuicksim(unittest.TestCase): # self.assertEqual(groundstate.get_charge_state((4, 1)), sidb_charge_state.NEUTRAL) # self.assertEqual(groundstate.get_charge_state((6, 1)), sidb_charge_state.NEGATIVE) # - # def test_perturber_and_sidb_pair_111(self): - # layout = sidb_111_lattice((4, 1)) - # layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) - # layout.assign_cell_type((1, 0), sidb_technology.cell_type.NORMAL) - # layout.assign_cell_type((2, 0), sidb_technology.cell_type.NORMAL) - # layout.assign_cell_type((3, 0), sidb_technology.cell_type.NORMAL) - # - # params = quicksim_params() - # params.simulation_parameters = sidb_simulation_parameters() - # params.simulation_parameters.mu_minus = -0.32 - # params.iteration_steps = 80 - # params.alpha = 0.7 - # self.assertEqual(params.iteration_steps, 80) - # self.assertEqual(params.alpha, 0.7) - # self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - # - # cds = charge_distribution_surface_111(layout) - # - # result = quicksim(layout, params) - # - # self.assertEqual(result.algorithm_name, "QuickSim") - # - # groundstate = determine_groundstate_from_simulation_results(result) - # - # self.assertEqual(len(groundstate), 1) - # - # self.assertEqual(groundstate[0].get_charge_state((0, 0)), sidb_charge_state.NEGATIVE) - # self.assertEqual(groundstate[0].get_charge_state((1, 0)), sidb_charge_state.NEUTRAL) - # self.assertEqual(groundstate[0].get_charge_state((2, 0)), sidb_charge_state.NEUTRAL) - # self.assertEqual(groundstate[0].get_charge_state((3, 0)), sidb_charge_state.NEGATIVE) + def test_perturber_and_sidb_pair_111(self): + layout = sidb_111_lattice((4, 1)) + layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((1, 0), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((2, 0), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((3, 0), sidb_technology.cell_type.NORMAL) + + params = quicksim_params() + params.simulation_parameters = sidb_simulation_parameters() + params.simulation_parameters.mu_minus = -0.32 + params.iteration_steps = 80 + params.alpha = 0.7 + self.assertEqual(params.iteration_steps, 80) + self.assertEqual(params.alpha, 0.7) + self.assertEqual(params.simulation_parameters.mu_minus, -0.32) + + cds = charge_distribution_surface_111(layout) + + result = quicksim(layout, params) + + self.assertEqual(result.algorithm_name, "QuickSim") + + groundstate = determine_groundstate_from_simulation_results(result) + + self.assertEqual(len(groundstate), 1) + + self.assertEqual(groundstate[0].get_charge_state((0, 0)), sidb_charge_state.NEGATIVE) + self.assertEqual(groundstate[0].get_charge_state((1, 0)), sidb_charge_state.NEUTRAL) + self.assertEqual(groundstate[0].get_charge_state((2, 0)), sidb_charge_state.NEUTRAL) + self.assertEqual(groundstate[0].get_charge_state((3, 0)), sidb_charge_state.NEGATIVE) if __name__ == '__main__': From b64ba0585405e0236db49e972d516541751adc0f Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 13:10:14 +0200 Subject: [PATCH 14/52] :green_heart: trial and error. --- .../simulation/sidb/test_quicksim.py | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 57907017d..ecd9b8aee 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -55,20 +55,20 @@ def test_perturber_and_sidb_pair_111(self): self.assertEqual(params.alpha, 0.7) self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - cds = charge_distribution_surface_111(layout) - - result = quicksim(layout, params) - - self.assertEqual(result.algorithm_name, "QuickSim") - - groundstate = determine_groundstate_from_simulation_results(result) - - self.assertEqual(len(groundstate), 1) - - self.assertEqual(groundstate[0].get_charge_state((0, 0)), sidb_charge_state.NEGATIVE) - self.assertEqual(groundstate[0].get_charge_state((1, 0)), sidb_charge_state.NEUTRAL) - self.assertEqual(groundstate[0].get_charge_state((2, 0)), sidb_charge_state.NEUTRAL) - self.assertEqual(groundstate[0].get_charge_state((3, 0)), sidb_charge_state.NEGATIVE) + # cds = charge_distribution_surface_111(layout) + # + # result = quicksim(layout, params) + # + # self.assertEqual(result.algorithm_name, "QuickSim") + # + # groundstate = determine_groundstate_from_simulation_results(result) + # + # self.assertEqual(len(groundstate), 1) + # + # self.assertEqual(groundstate[0].get_charge_state((0, 0)), sidb_charge_state.NEGATIVE) + # self.assertEqual(groundstate[0].get_charge_state((1, 0)), sidb_charge_state.NEUTRAL) + # self.assertEqual(groundstate[0].get_charge_state((2, 0)), sidb_charge_state.NEUTRAL) + # self.assertEqual(groundstate[0].get_charge_state((3, 0)), sidb_charge_state.NEGATIVE) if __name__ == '__main__': From 82b65ee7bcdba3d06e7455fcdf2ea03b9c830320 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 13:29:28 +0200 Subject: [PATCH 15/52] :green_heart: trial and error. --- .../simulation/sidb/test_time_to_solution.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py index 9a9b79981..88ae31718 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py @@ -23,24 +23,24 @@ def test_one_sidb_100_lattice(self): self.assertGreater(stats.time_to_solution, 0.0) self.assertGreater(stats.mean_single_runtime, 0.0) - def test_one_DBs_111_lattice(self): - layout = sidb_111_lattice((0, 0)) - layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) - - quicksim_parameter = quicksim_params() - quicksim_parameter.simulation_parameters = sidb_simulation_parameters(3, -0.3) - - tts_params = time_to_solution_params() - tts_params.engine = exhaustive_sidb_simulation_engine.QUICKEXACT - stats = time_to_solution_stats() - - cds = charge_distribution_surface_111(layout) - - time_to_solution(cds, quicksim_parameter, tts_params, stats) - - self.assertEqual(stats.acc, 100) - self.assertGreater(stats.time_to_solution, 0.0) - self.assertGreater(stats.mean_single_runtime, 0.0) + # def test_one_DBs_111_lattice(self): + # layout = sidb_111_lattice((0, 0)) + # layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) + # + # quicksim_parameter = quicksim_params() + # quicksim_parameter.simulation_parameters = sidb_simulation_parameters(3, -0.3) + # + # tts_params = time_to_solution_params() + # tts_params.engine = exhaustive_sidb_simulation_engine.QUICKEXACT + # stats = time_to_solution_stats() + # + # cds = charge_distribution_surface_111(layout) + # + # time_to_solution(cds, quicksim_parameter, tts_params, stats) + # + # self.assertEqual(stats.acc, 100) + # self.assertGreater(stats.time_to_solution, 0.0) + # self.assertGreater(stats.mean_single_runtime, 0.0) if __name__ == '__main__': unittest.main() From 7cdfc68ad906082996600087ce57cfa09c179aa5 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 13:43:08 +0200 Subject: [PATCH 16/52] :green_heart: trial and error. --- .../simulation/sidb/test_time_to_solution.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py index 88ae31718..85d79a501 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py @@ -14,14 +14,14 @@ def test_one_sidb_100_lattice(self): tts_params = time_to_solution_params() tts_params.engine = exhaustive_sidb_simulation_engine.QUICKEXACT stats = time_to_solution_stats() - - cds = charge_distribution_surface_100(layout) - - time_to_solution(cds, quicksim_parameter, tts_params, stats) - - self.assertEqual(stats.acc, 100) - self.assertGreater(stats.time_to_solution, 0.0) - self.assertGreater(stats.mean_single_runtime, 0.0) + # + # cds = charge_distribution_surface_100(layout) + # + # time_to_solution(cds, quicksim_parameter, tts_params, stats) + # + # self.assertEqual(stats.acc, 100) + # self.assertGreater(stats.time_to_solution, 0.0) + # self.assertGreater(stats.mean_single_runtime, 0.0) # def test_one_DBs_111_lattice(self): # layout = sidb_111_lattice((0, 0)) From 93a153164702d4538f37fda60f25afc6dbb9bd32 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 14:04:37 +0200 Subject: [PATCH 17/52] :green_heart: trial and error. --- .../test/algorithms/simulation/sidb/test_quicksim.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index ecd9b8aee..997e2909f 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -55,9 +55,9 @@ def test_perturber_and_sidb_pair_111(self): self.assertEqual(params.alpha, 0.7) self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - # cds = charge_distribution_surface_111(layout) + cds = charge_distribution_surface_111(layout) # - # result = quicksim(layout, params) + result = quicksim(layout, params) # # self.assertEqual(result.algorithm_name, "QuickSim") # From 9b08a1ff418d4d4dd532a22a3bd12e09f375ca2b Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 15:11:15 +0200 Subject: [PATCH 18/52] :green_heart: trial and error. --- .../algorithms/simulation/sidb/test_quicksim.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 997e2909f..87d9cf384 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -40,11 +40,11 @@ class TestQuicksim(unittest.TestCase): # self.assertEqual(groundstate.get_charge_state((6, 1)), sidb_charge_state.NEGATIVE) # def test_perturber_and_sidb_pair_111(self): - layout = sidb_111_lattice((4, 1)) - layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((1, 0), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((2, 0), sidb_technology.cell_type.NORMAL) - layout.assign_cell_type((3, 0), sidb_technology.cell_type.NORMAL) + layout_111 = sidb_111_lattice((4, 1)) + layout_111.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((1, 0), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((2, 0), sidb_technology.cell_type.NORMAL) + layout_111.assign_cell_type((3, 0), sidb_technology.cell_type.NORMAL) params = quicksim_params() params.simulation_parameters = sidb_simulation_parameters() @@ -55,9 +55,7 @@ def test_perturber_and_sidb_pair_111(self): self.assertEqual(params.alpha, 0.7) self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - cds = charge_distribution_surface_111(layout) - # - result = quicksim(layout, params) + result = quicksim(layout_111, params) # # self.assertEqual(result.algorithm_name, "QuickSim") # From 88e623407e141bbf9751e2ab9d8d3d2e9984f79e Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 15:28:29 +0200 Subject: [PATCH 19/52] :green_heart: delete thread count option. --- .../include/pyfiction/algorithms/simulation/sidb/quicksim.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp index a01c00f27..668b89c56 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp @@ -43,9 +43,6 @@ inline void quicksim(pybind11::module& m) .def_readwrite("iteration_steps", &fiction::quicksim_params::iteration_steps, DOC(fiction_quicksim_params_iteration_steps)) .def_readwrite("alpha", &fiction::quicksim_params::alpha, DOC(fiction_quicksim_params_alpha)) - .def_readwrite("number_threads", &fiction::quicksim_params::number_threads, - DOC(fiction_quicksim_params_number_threads)) - ; // NOTE be careful with the order of the following calls! Python will resolve the first matching overload! From 3a63a15ca0cfc55719ec6078469ea8352bab55e3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Jun 2024 13:28:56 +0000 Subject: [PATCH 20/52] =?UTF-8?q?=F0=9F=8E=A8=20Incorporated=20pre-commit?= =?UTF-8?q?=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../include/pyfiction/algorithms/simulation/sidb/quicksim.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp index 668b89c56..5b4ed5bd6 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp @@ -42,8 +42,7 @@ inline void quicksim(pybind11::module& m) DOC(fiction_quicksim_params_simulation_parameters)) .def_readwrite("iteration_steps", &fiction::quicksim_params::iteration_steps, DOC(fiction_quicksim_params_iteration_steps)) - .def_readwrite("alpha", &fiction::quicksim_params::alpha, DOC(fiction_quicksim_params_alpha)) - ; + .def_readwrite("alpha", &fiction::quicksim_params::alpha, DOC(fiction_quicksim_params_alpha)); // NOTE be careful with the order of the following calls! Python will resolve the first matching overload! From 27fac5ed6ec38e3c835730dd8998032bd6a3603d Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 15:43:40 +0200 Subject: [PATCH 21/52] :green_heart: delete thread count option. --- include/fiction/algorithms/simulation/sidb/quicksim.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fiction/algorithms/simulation/sidb/quicksim.hpp b/include/fiction/algorithms/simulation/sidb/quicksim.hpp index beb3ec8a0..c1f2f807d 100644 --- a/include/fiction/algorithms/simulation/sidb/quicksim.hpp +++ b/include/fiction/algorithms/simulation/sidb/quicksim.hpp @@ -42,7 +42,7 @@ struct quicksim_params /** * Number of threads to spawn. By default the number of threads is set to the number of available hardware threads. */ - uint64_t number_threads{std::thread::hardware_concurrency()}; + uint64_t number_threads{1}; }; /** From 383de5fd2faadfbfb1f0e86397abd89a1c400e87 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 20 Jun 2024 15:58:32 +0200 Subject: [PATCH 22/52] :green_heart: trial and error. --- .../test/algorithms/simulation/sidb/test_quicksim.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 87d9cf384..669b2d733 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -55,7 +55,9 @@ def test_perturber_and_sidb_pair_111(self): self.assertEqual(params.alpha, 0.7) self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - result = quicksim(layout_111, params) + cds = charge_distribution_surface_100(layout_111) + + result = quicksim(cds, params) # # self.assertEqual(result.algorithm_name, "QuickSim") # From d6ab97dc90d7be5b7bb8333e05f783d9ac9a8342 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Fri, 21 Jun 2024 08:00:40 +0200 Subject: [PATCH 23/52] :green_heart: trial and error. --- .../pyfiction/test/algorithms/simulation/sidb/test_quicksim.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 669b2d733..ffadbec69 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -55,7 +55,7 @@ def test_perturber_and_sidb_pair_111(self): self.assertEqual(params.alpha, 0.7) self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - cds = charge_distribution_surface_100(layout_111) + cds = charge_distribution_surface_111(layout_111) result = quicksim(cds, params) # From 7ef2e8637e383e87c5c59da1c9b70db4392bb6f8 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Mon, 24 Jun 2024 15:24:59 +0200 Subject: [PATCH 24/52] :green_heart: trial and error. --- .../test/algorithms/simulation/sidb/test_quicksim.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index ffadbec69..2f07688dc 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -55,9 +55,9 @@ def test_perturber_and_sidb_pair_111(self): self.assertEqual(params.alpha, 0.7) self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - cds = charge_distribution_surface_111(layout_111) + #cds = charge_distribution_surface_111(layout_111) - result = quicksim(cds, params) + #result = quicksim(cds, params) # # self.assertEqual(result.algorithm_name, "QuickSim") # From b4aca911f10ae4fa95455d393940129d1f36bc0d Mon Sep 17 00:00:00 2001 From: Drewniok Date: Mon, 24 Jun 2024 16:48:49 +0200 Subject: [PATCH 25/52] :green_heart: trial and error. --- .../test/algorithms/simulation/sidb/test_quicksim.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 2f07688dc..f685ade41 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -6,12 +6,12 @@ class TestQuicksim(unittest.TestCase): # def test_perturber_and_sidb_pair(self): - # layout = sidb_100_lattice((10, 10)) + layout = sidb_100_lattice((10, 10)) # layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL) # layout.assign_cell_type((4, 1), sidb_technology.cell_type.NORMAL) # layout.assign_cell_type((6, 1), sidb_technology.cell_type.NORMAL) # - # params = quicksim_params() + params = quicksim_params() # params.simulation_parameters = sidb_simulation_parameters() # params.iteration_steps = 80 # params.alpha = 0.7 @@ -26,9 +26,9 @@ class TestQuicksim(unittest.TestCase): # self.assertEqual(params_one.alpha, 0.4) # self.assertEqual(params_one.number_threads, 1) # - # cds = charge_distribution_surface(layout) + cds = charge_distribution_surface(layout) # - # result = quicksim(layout, params) + result = quicksim(layout, params) # # self.assertEqual(result.algorithm_name, "QuickSim") # self.assertLessEqual(len(result.charge_distributions), 80) From 71d93740d8e3ff3bbfcc7554c806c9fb799db447 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 25 Jun 2024 08:25:19 +0200 Subject: [PATCH 26/52] :green_heart: trial and error. --- .../pyfiction/test/algorithms/simulation/sidb/test_quicksim.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index f685ade41..75cd50884 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -5,7 +5,7 @@ class TestQuicksim(unittest.TestCase): - # def test_perturber_and_sidb_pair(self): + def test_perturber_and_sidb_pair(self): layout = sidb_100_lattice((10, 10)) # layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL) # layout.assign_cell_type((4, 1), sidb_technology.cell_type.NORMAL) From 9724870ef7461a17ee063e35dd36d101f8ba9ca8 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 25 Jun 2024 09:48:58 +0200 Subject: [PATCH 27/52] :green_heart: trial and error. --- .../simulation/sidb/test_quicksim.py | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 75cd50884..4843895f0 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -6,29 +6,31 @@ class TestQuicksim(unittest.TestCase): def test_perturber_and_sidb_pair(self): - layout = sidb_100_lattice((10, 10)) - # layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL) - # layout.assign_cell_type((4, 1), sidb_technology.cell_type.NORMAL) - # layout.assign_cell_type((6, 1), sidb_technology.cell_type.NORMAL) + layout = sidb_100_lattice((10, 10)) + layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((4, 1), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((6, 1), sidb_technology.cell_type.NORMAL) # - params = quicksim_params() - # params.simulation_parameters = sidb_simulation_parameters() - # params.iteration_steps = 80 - # params.alpha = 0.7 - # self.assertEqual(params.iteration_steps, 80) - # self.assertEqual(params.alpha, 0.7) - # - # params_one = quicksim_params() - # params_one.iteration_steps = 50 - # params_one.alpha = 0.4 - # params_one.number_threads = 1 - # self.assertEqual(params_one.iteration_steps, 50) - # self.assertEqual(params_one.alpha, 0.4) - # self.assertEqual(params_one.number_threads, 1) + params = quicksim_params() + params.simulation_parameters = sidb_simulation_parameters() + params.iteration_steps = 80 + params.alpha = 0.7 + self.assertEqual(params.iteration_steps, 80) + self.assertEqual(params.alpha, 0.7) + + params_one = quicksim_params() + params_one.iteration_steps = 50 + params_one.alpha = 0.4 + #params_one.number_threads = 1 + self.assertEqual(params_one.iteration_steps, 50) + self.assertEqual(params_one.alpha, 0.4) + # - cds = charge_distribution_surface(layout) + cds = charge_distribution_surface(layout) # - result = quicksim(layout, params) + result = quicksim(layout, params) + + print("len: " + str(len(result.charge_distributions))) # # self.assertEqual(result.algorithm_name, "QuickSim") # self.assertLessEqual(len(result.charge_distributions), 80) From bd687991eadd322bf8d5b407cd9ee65cca9fc86b Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 25 Jun 2024 10:24:35 +0200 Subject: [PATCH 28/52] :green_heart: trial and error. --- .../algorithms/simulation/sidb/quicksim.hpp | 111 +++++++----------- 1 file changed, 41 insertions(+), 70 deletions(-) diff --git a/include/fiction/algorithms/simulation/sidb/quicksim.hpp b/include/fiction/algorithms/simulation/sidb/quicksim.hpp index c1f2f807d..3efd5cf4c 100644 --- a/include/fiction/algorithms/simulation/sidb/quicksim.hpp +++ b/include/fiction/algorithms/simulation/sidb/quicksim.hpp @@ -124,83 +124,54 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = charge_lyt.assign_all_charge_states(sidb_charge_state::NEUTRAL); charge_lyt.update_after_charge_change(); - // If the number of threads is initially set to zero, the simulation is run with one thread. - const uint64_t num_threads = std::max(ps.number_threads, uint64_t{1}); + charge_distribution_surface charge_lyt_copy{charge_lyt}; - // split the iterations among threads - const auto iter_per_thread = - std::max(ps.iteration_steps / num_threads, - uint64_t{1}); // If the number of set threads is greater than the number of iterations, the - // number of threads defines how many times QuickSim is repeated + for (uint64_t l = 0ul; l < 1000; ++l) + { + for (uint64_t i = 0ul; i < charge_lyt.num_cells(); ++i) + { + { + if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != + negative_sidb_indices.cend()) + { + continue; + } + } - std::vector threads{}; - threads.reserve(num_threads); - std::mutex mutex{}; // used to control access to shared resources + std::vector index_start{i}; - for (uint64_t z = 0ul; z < num_threads; z++) - { - threads.emplace_back( - [&] + charge_lyt_copy.assign_all_charge_states(sidb_charge_state::NEUTRAL); + + for (const auto& index : negative_sidb_indices) { - charge_distribution_surface charge_lyt_copy{charge_lyt}; + charge_lyt_copy.assign_charge_state_by_cell_index(static_cast(index), + sidb_charge_state::NEGATIVE); + index_start.push_back(static_cast(index)); + } - for (uint64_t l = 0ul; l < iter_per_thread; ++l) + charge_lyt_copy.assign_charge_state_by_cell_index(i, sidb_charge_state::NEGATIVE); + charge_lyt_copy.update_after_charge_change(); + + if (charge_lyt_copy.is_physically_valid()) + { + st.charge_distributions.push_back(charge_distribution_surface{charge_lyt_copy}); + } + + const auto upper_limit = + std::min(static_cast(static_cast(charge_lyt_copy.num_cells()) / 1.5), + charge_lyt.num_cells() - negative_sidb_indices.size()); + + for (uint64_t num = 0ul; num < upper_limit; num++) + { + charge_lyt_copy.adjacent_search(ps.alpha, index_start); + charge_lyt_copy.validity_check(); + + if (charge_lyt_copy.is_physically_valid()) { - for (uint64_t i = 0ul; i < charge_lyt.num_cells(); ++i) - { - { - const std::lock_guard lock{mutex}; - if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != - negative_sidb_indices.cend()) - { - continue; - } - } - - std::vector index_start{i}; - - charge_lyt_copy.assign_all_charge_states(sidb_charge_state::NEUTRAL); - - for (const auto& index : negative_sidb_indices) - { - charge_lyt_copy.assign_charge_state_by_cell_index(static_cast(index), - sidb_charge_state::NEGATIVE); - index_start.push_back(static_cast(index)); - } - - charge_lyt_copy.assign_charge_state_by_cell_index(i, sidb_charge_state::NEGATIVE); - charge_lyt_copy.update_after_charge_change(); - - if (charge_lyt_copy.is_physically_valid()) - { - const std::lock_guard lock{mutex}; - st.charge_distributions.push_back(charge_distribution_surface{charge_lyt_copy}); - } - - const auto upper_limit = - std::min(static_cast(static_cast(charge_lyt_copy.num_cells()) / 1.5), - charge_lyt.num_cells() - negative_sidb_indices.size()); - - for (uint64_t num = 0ul; num < upper_limit; num++) - { - charge_lyt_copy.adjacent_search(ps.alpha, index_start); - charge_lyt_copy.validity_check(); - - if (charge_lyt_copy.is_physically_valid()) - { - const std::lock_guard lock{mutex}; - st.charge_distributions.push_back( - charge_distribution_surface{charge_lyt_copy}); - } - } - } + st.charge_distributions.push_back(charge_distribution_surface{charge_lyt_copy}); } - }); - } - - for (auto& thread : threads) - { - thread.join(); + } + } } } From 594db7ac6dfe94067829d8c5d31ab06dd14fbdf6 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 25 Jun 2024 11:11:00 +0200 Subject: [PATCH 29/52] :green_heart: trial and error. --- .../simulation/sidb/test_quicksim.py | 51 +++++++++---------- .../algorithms/simulation/sidb/quicksim.hpp | 2 +- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 4843895f0..53067d82c 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -21,25 +21,24 @@ def test_perturber_and_sidb_pair(self): params_one = quicksim_params() params_one.iteration_steps = 50 params_one.alpha = 0.4 - #params_one.number_threads = 1 + self.assertEqual(params_one.iteration_steps, 50) self.assertEqual(params_one.alpha, 0.4) - # cds = charge_distribution_surface(layout) - # + result = quicksim(layout, params) print("len: " + str(len(result.charge_distributions))) - # - # self.assertEqual(result.algorithm_name, "QuickSim") - # self.assertLessEqual(len(result.charge_distributions), 80) - # - # groundstate = result.charge_distributions[0] - # - # self.assertEqual(groundstate.get_charge_state((0, 1)), sidb_charge_state.NEGATIVE) - # self.assertEqual(groundstate.get_charge_state((4, 1)), sidb_charge_state.NEUTRAL) - # self.assertEqual(groundstate.get_charge_state((6, 1)), sidb_charge_state.NEGATIVE) + + self.assertEqual(result.algorithm_name, "QuickSim") + self.assertLessEqual(len(result.charge_distributions), 80) + + groundstate = result.charge_distributions[0] + + self.assertEqual(groundstate.get_charge_state((0, 1)), sidb_charge_state.NEGATIVE) + self.assertEqual(groundstate.get_charge_state((4, 1)), sidb_charge_state.NEUTRAL) + self.assertEqual(groundstate.get_charge_state((6, 1)), sidb_charge_state.NEGATIVE) # def test_perturber_and_sidb_pair_111(self): layout_111 = sidb_111_lattice((4, 1)) @@ -57,20 +56,20 @@ def test_perturber_and_sidb_pair_111(self): self.assertEqual(params.alpha, 0.7) self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - #cds = charge_distribution_surface_111(layout_111) - - #result = quicksim(cds, params) - # - # self.assertEqual(result.algorithm_name, "QuickSim") - # - # groundstate = determine_groundstate_from_simulation_results(result) - # - # self.assertEqual(len(groundstate), 1) - # - # self.assertEqual(groundstate[0].get_charge_state((0, 0)), sidb_charge_state.NEGATIVE) - # self.assertEqual(groundstate[0].get_charge_state((1, 0)), sidb_charge_state.NEUTRAL) - # self.assertEqual(groundstate[0].get_charge_state((2, 0)), sidb_charge_state.NEUTRAL) - # self.assertEqual(groundstate[0].get_charge_state((3, 0)), sidb_charge_state.NEGATIVE) + cds = charge_distribution_surface_111(layout_111) + + result = quicksim(cds, params) + + self.assertEqual(result.algorithm_name, "QuickSim") + + groundstate = determine_groundstate_from_simulation_results(result) + + self.assertEqual(len(groundstate), 1) + + self.assertEqual(groundstate[0].get_charge_state((0, 0)), sidb_charge_state.NEGATIVE) + self.assertEqual(groundstate[0].get_charge_state((1, 0)), sidb_charge_state.NEUTRAL) + self.assertEqual(groundstate[0].get_charge_state((2, 0)), sidb_charge_state.NEUTRAL) + self.assertEqual(groundstate[0].get_charge_state((3, 0)), sidb_charge_state.NEGATIVE) if __name__ == '__main__': diff --git a/include/fiction/algorithms/simulation/sidb/quicksim.hpp b/include/fiction/algorithms/simulation/sidb/quicksim.hpp index 3efd5cf4c..192106716 100644 --- a/include/fiction/algorithms/simulation/sidb/quicksim.hpp +++ b/include/fiction/algorithms/simulation/sidb/quicksim.hpp @@ -126,7 +126,7 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = charge_distribution_surface charge_lyt_copy{charge_lyt}; - for (uint64_t l = 0ul; l < 1000; ++l) + for (uint64_t l = 0ul; l < 10; ++l) { for (uint64_t i = 0ul; i < charge_lyt.num_cells(); ++i) { From f77bb9ca5048a9cfc17d86a92a7a1a44c4ae8c17 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 25 Jun 2024 12:31:44 +0200 Subject: [PATCH 30/52] :green_heart: only one thread. --- .../algorithms/simulation/sidb/quicksim.hpp | 113 +++++++++++------- 1 file changed, 71 insertions(+), 42 deletions(-) diff --git a/include/fiction/algorithms/simulation/sidb/quicksim.hpp b/include/fiction/algorithms/simulation/sidb/quicksim.hpp index 192106716..fd2375e29 100644 --- a/include/fiction/algorithms/simulation/sidb/quicksim.hpp +++ b/include/fiction/algorithms/simulation/sidb/quicksim.hpp @@ -42,7 +42,7 @@ struct quicksim_params /** * Number of threads to spawn. By default the number of threads is set to the number of available hardware threads. */ - uint64_t number_threads{1}; + uint64_t number_threads{std::thread::hardware_concurrency()}; }; /** @@ -124,54 +124,83 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = charge_lyt.assign_all_charge_states(sidb_charge_state::NEUTRAL); charge_lyt.update_after_charge_change(); - charge_distribution_surface charge_lyt_copy{charge_lyt}; + // If the number of threads is initially set to zero, the simulation is run with one thread. + const uint64_t num_threads = 1; - for (uint64_t l = 0ul; l < 10; ++l) - { - for (uint64_t i = 0ul; i < charge_lyt.num_cells(); ++i) - { - { - if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != - negative_sidb_indices.cend()) - { - continue; - } - } - - std::vector index_start{i}; - - charge_lyt_copy.assign_all_charge_states(sidb_charge_state::NEUTRAL); - - for (const auto& index : negative_sidb_indices) - { - charge_lyt_copy.assign_charge_state_by_cell_index(static_cast(index), - sidb_charge_state::NEGATIVE); - index_start.push_back(static_cast(index)); - } + // split the iterations among threads + const auto iter_per_thread = + std::max(ps.iteration_steps / num_threads, + uint64_t{1}); // If the number of set threads is greater than the number of iterations, the + // number of threads defines how many times QuickSim is repeated - charge_lyt_copy.assign_charge_state_by_cell_index(i, sidb_charge_state::NEGATIVE); - charge_lyt_copy.update_after_charge_change(); + std::vector threads{}; + threads.reserve(num_threads); + std::mutex mutex{}; // used to control access to shared resources - if (charge_lyt_copy.is_physically_valid()) - { - st.charge_distributions.push_back(charge_distribution_surface{charge_lyt_copy}); - } - - const auto upper_limit = - std::min(static_cast(static_cast(charge_lyt_copy.num_cells()) / 1.5), - charge_lyt.num_cells() - negative_sidb_indices.size()); - - for (uint64_t num = 0ul; num < upper_limit; num++) + for (uint64_t z = 0ul; z < num_threads; z++) + { + threads.emplace_back( + [&] { - charge_lyt_copy.adjacent_search(ps.alpha, index_start); - charge_lyt_copy.validity_check(); + charge_distribution_surface charge_lyt_copy{charge_lyt}; - if (charge_lyt_copy.is_physically_valid()) + for (uint64_t l = 0ul; l < iter_per_thread; ++l) { - st.charge_distributions.push_back(charge_distribution_surface{charge_lyt_copy}); + for (uint64_t i = 0ul; i < charge_lyt.num_cells(); ++i) + { + { + const std::lock_guard lock{mutex}; + if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != + negative_sidb_indices.cend()) + { + continue; + } + } + + std::vector index_start{i}; + + charge_lyt_copy.assign_all_charge_states(sidb_charge_state::NEUTRAL); + + for (const auto& index : negative_sidb_indices) + { + charge_lyt_copy.assign_charge_state_by_cell_index(static_cast(index), + sidb_charge_state::NEGATIVE); + index_start.push_back(static_cast(index)); + } + + charge_lyt_copy.assign_charge_state_by_cell_index(i, sidb_charge_state::NEGATIVE); + charge_lyt_copy.update_after_charge_change(); + + if (charge_lyt_copy.is_physically_valid()) + { + const std::lock_guard lock{mutex}; + st.charge_distributions.push_back(charge_distribution_surface{charge_lyt_copy}); + } + + const auto upper_limit = + std::min(static_cast(static_cast(charge_lyt_copy.num_cells())), + charge_lyt.num_cells() - negative_sidb_indices.size()); + + for (uint64_t num = 0ul; num < upper_limit; num++) + { + charge_lyt_copy.adjacent_search(ps.alpha, index_start); + charge_lyt_copy.validity_check(); + + if (charge_lyt_copy.is_physically_valid()) + { + const std::lock_guard lock{mutex}; + st.charge_distributions.push_back( + charge_distribution_surface{charge_lyt_copy}); + } + } + } } - } - } + }); + } + + for (auto& thread : threads) + { + thread.join(); } } From d2de859239a5fa3355ad752f6915d7e3867b266f Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 25 Jun 2024 13:26:15 +0200 Subject: [PATCH 31/52] :green_heart: small changes in multithreading. --- include/fiction/algorithms/simulation/sidb/quicksim.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/fiction/algorithms/simulation/sidb/quicksim.hpp b/include/fiction/algorithms/simulation/sidb/quicksim.hpp index fd2375e29..e6dc4b937 100644 --- a/include/fiction/algorithms/simulation/sidb/quicksim.hpp +++ b/include/fiction/algorithms/simulation/sidb/quicksim.hpp @@ -125,7 +125,7 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = charge_lyt.update_after_charge_change(); // If the number of threads is initially set to zero, the simulation is run with one thread. - const uint64_t num_threads = 1; + const uint64_t num_threads = std::max(ps.number_threads, uint64_t{1}); // split the iterations among threads const auto iter_per_thread = @@ -149,7 +149,6 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = for (uint64_t i = 0ul; i < charge_lyt.num_cells(); ++i) { { - const std::lock_guard lock{mutex}; if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != negative_sidb_indices.cend()) { From 9e63dc5342a10b1b9eed493852d2ca1d1d80dfe5 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 25 Jun 2024 14:24:29 +0200 Subject: [PATCH 32/52] :green_heart: use ``future`` for multithreading. --- .../algorithms/simulation/sidb/quicksim.hpp | 31 +++++++++---------- test/benchmark/simulation.cpp | 3 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/fiction/algorithms/simulation/sidb/quicksim.hpp b/include/fiction/algorithms/simulation/sidb/quicksim.hpp index e6dc4b937..cee45d43a 100644 --- a/include/fiction/algorithms/simulation/sidb/quicksim.hpp +++ b/include/fiction/algorithms/simulation/sidb/quicksim.hpp @@ -15,8 +15,8 @@ #include #include +#include #include -#include #include namespace fiction @@ -77,6 +77,7 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = st.charge_distributions.reserve(ps.iteration_steps); mockturtle::stopwatch<>::duration time_counter{}; + std::mutex mutex{}; // measure run time (artificial scope) { @@ -133,14 +134,14 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = uint64_t{1}); // If the number of set threads is greater than the number of iterations, the // number of threads defines how many times QuickSim is repeated - std::vector threads{}; - threads.reserve(num_threads); - std::mutex mutex{}; // used to control access to shared resources + std::vector> futures; + futures.reserve(num_threads); for (uint64_t z = 0ul; z < num_threads; z++) { - threads.emplace_back( - [&] + futures.emplace_back(std::async( + std::launch::async, + [&st, &charge_lyt, negative_sidb_indices, iter_per_thread, ps, num_threads, &mutex] { charge_distribution_surface charge_lyt_copy{charge_lyt}; @@ -148,12 +149,10 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = { for (uint64_t i = 0ul; i < charge_lyt.num_cells(); ++i) { + if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != + negative_sidb_indices.cend()) { - if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != - negative_sidb_indices.cend()) - { - continue; - } + continue; } std::vector index_start{i}; @@ -172,7 +171,7 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = if (charge_lyt_copy.is_physically_valid()) { - const std::lock_guard lock{mutex}; + const std::lock_guard lock{mutex}; st.charge_distributions.push_back(charge_distribution_surface{charge_lyt_copy}); } @@ -187,19 +186,19 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = if (charge_lyt_copy.is_physically_valid()) { - const std::lock_guard lock{mutex}; + const std::lock_guard lock{mutex}; st.charge_distributions.push_back( charge_distribution_surface{charge_lyt_copy}); } } } } - }); + })); } - for (auto& thread : threads) + for (auto& future : futures) { - thread.join(); + future.get(); } } diff --git a/test/benchmark/simulation.cpp b/test/benchmark/simulation.cpp index 320a59f4e..f5603e4d9 100644 --- a/test/benchmark/simulation.cpp +++ b/test/benchmark/simulation.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include using namespace fiction; @@ -61,7 +62,7 @@ TEST_CASE("Benchmark simulators", "[benchmark]") BENCHMARK("QuickExact") { - const quickexact_params sim_params{sidb_simulation_parameters{2, -0.32}}; + const quickexact_params> sim_params{sidb_simulation_parameters{2, -0.32}}; return quickexact(lyt, sim_params); }; From 559fa865776aafd234c1354b3edada1cbd2f1f1f Mon Sep 17 00:00:00 2001 From: Drewniok Date: Tue, 25 Jun 2024 15:24:35 +0200 Subject: [PATCH 33/52] :green_heart: use sanitizer. --- .github/workflows/windows.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 049594f33..57cdf112d 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -98,6 +98,9 @@ jobs: -DFICTION_Z3=ON -DFICTION_WARNINGS_AS_ERRORS=OFF -DMOCKTURTLE_EXAMPLES=OFF + -DFICTION_ENABLE_SANITIZER_ADDRESS=ON + -DFICTION_ENABLE_SANITIZER_LEAK=ON + -DFICTION_ENABLE_SANITIZER_UNDEFINED=ON - name: Build (Debug) working-directory: ${{github.workspace}}\build_debug From c736f9aec94d3d3bcff7c67da031982a94ac83ee Mon Sep 17 00:00:00 2001 From: Drewniok Date: Wed, 26 Jun 2024 12:39:14 +0200 Subject: [PATCH 34/52] :green_heart: revert use of sanitizer. --- .github/workflows/windows.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 57cdf112d..049594f33 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -98,9 +98,6 @@ jobs: -DFICTION_Z3=ON -DFICTION_WARNINGS_AS_ERRORS=OFF -DMOCKTURTLE_EXAMPLES=OFF - -DFICTION_ENABLE_SANITIZER_ADDRESS=ON - -DFICTION_ENABLE_SANITIZER_LEAK=ON - -DFICTION_ENABLE_SANITIZER_UNDEFINED=ON - name: Build (Debug) working-directory: ${{github.workspace}}\build_debug From 1ba9e9fd6253edd8f4802f54727cccb51c348e48 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 08:51:11 +0200 Subject: [PATCH 35/52] :art: revert changes. --- .../physical_design/test_design_sidb_gates.py | 132 +++++++++--------- .../sidb/test_critical_temperature.py | 12 +- .../sidb/test_operational_domain.py | 94 ++++++------- .../simulation/sidb/test_time_to_solution.py | 54 +++---- 4 files changed, 146 insertions(+), 146 deletions(-) diff --git a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py index a87aa3653..299af40a2 100644 --- a/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py +++ b/bindings/pyfiction/test/algorithms/physical_design/test_design_sidb_gates.py @@ -6,24 +6,24 @@ class TestDesignSiDBGates(unittest.TestCase): def test_siqad_and_gate_skeleton_100(self): - layout_100 = sidb_100_lattice((20, 20)) + layout = sidb_100_lattice((20, 20)) - layout_100.assign_cell_type((0, 1), sidb_technology.cell_type.INPUT) - layout_100.assign_cell_type((2, 3), sidb_technology.cell_type.INPUT) + layout.assign_cell_type((0, 1), sidb_technology.cell_type.INPUT) + layout.assign_cell_type((2, 3), sidb_technology.cell_type.INPUT) - layout_100.assign_cell_type((20, 1), sidb_technology.cell_type.INPUT) - layout_100.assign_cell_type((18, 3), sidb_technology.cell_type.INPUT) + layout.assign_cell_type((20, 1), sidb_technology.cell_type.INPUT) + layout.assign_cell_type((18, 3), sidb_technology.cell_type.INPUT) - layout_100.assign_cell_type((4, 5), sidb_technology.cell_type.NORMAL) - layout_100.assign_cell_type((6, 7), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((4, 5), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((6, 7), sidb_technology.cell_type.NORMAL) - layout_100.assign_cell_type((14, 7), sidb_technology.cell_type.NORMAL) - layout_100.assign_cell_type((16, 5), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((14, 7), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((16, 5), sidb_technology.cell_type.NORMAL) - layout_100.assign_cell_type((10, 12), sidb_technology.cell_type.OUTPUT) - layout_100.assign_cell_type((10, 14), sidb_technology.cell_type.OUTPUT) + layout.assign_cell_type((10, 12), sidb_technology.cell_type.OUTPUT) + layout.assign_cell_type((10, 14), sidb_technology.cell_type.OUTPUT) - layout_100.assign_cell_type((10, 19), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((10, 19), sidb_technology.cell_type.NORMAL) params = design_sidb_gates_params() params.simulation_parameters.base = 2 @@ -33,60 +33,60 @@ def test_siqad_and_gate_skeleton_100(self): params.number_of_sidbs = 1 params.sim_engine = sidb_simulation_engine.QUICKEXACT - # self.assertEqual(params.simulation_parameters.mu_minus, -0.28) - # self.assertEqual(params.number_of_sidbs, 1) - # self.assertEqual(params.canvas[0], (4, 8)) - # self.assertEqual(params.canvas[1], (14, 11)) - # - # designed_gates = design_sidb_gates(layout_100, [create_and_tt()], params) - # - # self.assertEqual(len(designed_gates), 23) - - # def test_nor_gate_111(self): - # layout_111 = sidb_111_lattice((20, 20)) - # - # layout_111.assign_cell_type((0, 0), sidb_technology.cell_type.INPUT) - # layout_111.assign_cell_type((25, 0), sidb_technology.cell_type.INPUT) - # - # layout_111.assign_cell_type((23, 3), sidb_technology.cell_type.INPUT) - # layout_111.assign_cell_type((1, 3), sidb_technology.cell_type.INPUT) - # - # layout_111.assign_cell_type((4, 8), sidb_technology.cell_type.NORMAL) - # layout_111.assign_cell_type((21, 4), sidb_technology.cell_type.NORMAL) - # - # layout_111.assign_cell_type((5, 11), sidb_technology.cell_type.NORMAL) - # layout_111.assign_cell_type((19, 11), sidb_technology.cell_type.NORMAL) - # - # layout_111.assign_cell_type((8, 16), sidb_technology.cell_type.NORMAL) - # layout_111.assign_cell_type((17, 16), sidb_technology.cell_type.NORMAL) - # - # layout_111.assign_cell_type((9, 19), sidb_technology.cell_type.NORMAL) - # layout_111.assign_cell_type((15, 19), sidb_technology.cell_type.NORMAL) - # - # layout_111.assign_cell_type((15, 43), sidb_technology.cell_type.NORMAL) - # layout_111.assign_cell_type((17, 46), sidb_technology.cell_type.NORMAL) - # - # layout_111.assign_cell_type((19, 51), sidb_technology.cell_type.OUTPUT) - # layout_111.assign_cell_type((21, 54), sidb_technology.cell_type.OUTPUT) - # - # layout_111.assign_cell_type((23, 59), sidb_technology.cell_type.NORMAL) - # - # params = design_sidb_gates_params() - # params.simulation_parameters.base = 2 - # params.simulation_parameters.mu_minus = -0.32 - # params.design_mode = design_sidb_gates_mode.EXHAUSTIVE - # params.canvas = [(10, 22), (14, 34)] - # params.number_of_sidbs = 3 - # params.sim_engine = sidb_simulation_engine.QUICKEXACT - # - # self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - # self.assertEqual(params.number_of_sidbs, 3) - # self.assertEqual(params.canvas[0], (10, 22)) - # self.assertEqual(params.canvas[1], (14, 34)) - # - # designed_gates = design_sidb_gates(layout_111, [create_nor_tt()], params) - # - # self.assertEqual(len(designed_gates), 206) + self.assertEqual(params.simulation_parameters.mu_minus, -0.28) + self.assertEqual(params.number_of_sidbs, 1) + self.assertEqual(params.canvas[0], (4, 8, 0)) + self.assertEqual(params.canvas[1], (14, 11)) + + designed_gates = design_sidb_gates(layout, [create_and_tt()], params) + + self.assertEqual(len(designed_gates), 23) + + def test_nor_gate_111(self): + layout = sidb_111_lattice((20, 20)) + + layout.assign_cell_type((0, 0), sidb_technology.cell_type.INPUT) + layout.assign_cell_type((25, 0), sidb_technology.cell_type.INPUT) + + layout.assign_cell_type((23, 3), sidb_technology.cell_type.INPUT) + layout.assign_cell_type((1, 3), sidb_technology.cell_type.INPUT) + + layout.assign_cell_type((4, 8), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((21, 4), sidb_technology.cell_type.NORMAL) + + layout.assign_cell_type((5, 11), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((19, 11), sidb_technology.cell_type.NORMAL) + + layout.assign_cell_type((8, 16), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((17, 16), sidb_technology.cell_type.NORMAL) + + layout.assign_cell_type((9, 19), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((15, 19), sidb_technology.cell_type.NORMAL) + + layout.assign_cell_type((15, 43), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((17, 46), sidb_technology.cell_type.NORMAL) + + layout.assign_cell_type((19, 51), sidb_technology.cell_type.OUTPUT) + layout.assign_cell_type((21, 54), sidb_technology.cell_type.OUTPUT) + + layout.assign_cell_type((23, 59), sidb_technology.cell_type.NORMAL) + + params = design_sidb_gates_params() + params.simulation_parameters.base = 2 + params.simulation_parameters.mu_minus = -0.32 + params.design_mode = design_sidb_gates_mode.EXHAUSTIVE + params.canvas = [(10, 22), (14, 34)] + params.number_of_sidbs = 3 + params.sim_engine = sidb_simulation_engine.QUICKEXACT + + self.assertEqual(params.simulation_parameters.mu_minus, -0.32) + self.assertEqual(params.number_of_sidbs, 3) + self.assertEqual(params.canvas[0], (10, 22, 0)) + self.assertEqual(params.canvas[1], (14, 34)) + + designed_gates = design_sidb_gates(layout, [create_nor_tt()], params) + + self.assertEqual(len(designed_gates), 206) if __name__ == '__main__': diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_critical_temperature.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_critical_temperature.py index a6cfd454f..ac6574928 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_critical_temperature.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_critical_temperature.py @@ -61,7 +61,7 @@ def test_gate_based_simulation(self): def test_bestagon_inv(self): layout = read_sqd_layout_100(dir_path + "/../../../resources/hex_11_inputsdbp_inv_straight_v0_manual.sqd", - "inverter_input_0") + "inverter_input_0") params = critical_temperature_params() params.engine = simulation_engine.APPROXIMATE @@ -71,14 +71,14 @@ def test_bestagon_inv(self): cds = charge_distribution_surface_100(layout) spec = [create_not_tt()] - # self.assertLessEqual(critical_temperature_gate_based(cds, spec, params, stats), 400) - # - # self.assertEqual(stats.algorithm_name, "QuickSim") - # self.assertGreater(stats.num_valid_lyt, 1) + self.assertLessEqual(critical_temperature_gate_based(cds, spec, params, stats), 400) + + self.assertEqual(stats.algorithm_name, "QuickSim") + self.assertGreater(stats.num_valid_lyt, 1) def test_bestagon_inv_with_different_mu(self): layout = read_sqd_layout_100(dir_path + "/../../../resources/hex_11_inputsdbp_inv_straight_v0_manual.sqd", - "inverter_input_0") + "inverter_input_0") params = critical_temperature_params() params.simulation_parameters.base = 2 diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py index 208903a4a..d9a35d9e8 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_operational_domain.py @@ -22,53 +22,53 @@ def test_xor_gate_100_lattice(self): params.x_step = 0.01 params.y_step = 0.01 - # stats_grid = operational_domain_stats() - # opdomain = operational_domain_grid_search(lyt, [create_xor_tt()], params, stats_grid) - # self.assertGreater(stats_grid.num_operational_parameter_combinations, 0) - # - # stats_flood_fill = operational_domain_stats() - # opdomain = operational_domain_flood_fill(lyt, [create_xor_tt()], 100, params, stats_flood_fill) - # self.assertGreater(stats_flood_fill.num_operational_parameter_combinations, 0) - # - # stats_random_sampling = operational_domain_stats() - # opdomain = operational_domain_random_sampling(lyt, [create_xor_tt()], 100, params, stats_random_sampling) - # self.assertGreater(stats_random_sampling.num_operational_parameter_combinations, 0) - # - # stats_contour_tracing = operational_domain_stats() - # opdomain = operational_domain_contour_tracing(lyt, [create_xor_tt()], 100, params, stats_contour_tracing) - # self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) - - # def test_and_gate_111_lattice(self): - # lyt = read_sqd_layout_111(dir_path + "/../../../resources/AND_mu_032_0.sqd") - # - # params = operational_domain_params() - # - # params.sim_engine = sidb_simulation_engine.QUICKEXACT - # params.simulation_parameters.base = 2 - # params.x_dimension = sweep_parameter.EPSILON_R - # params.y_dimension = sweep_parameter.LAMBDA_TF - # params.x_min = 5.60 - # params.x_max = 5.64 - # params.x_step = 0.01 - # params.y_min = 5.00 - # params.y_max = 5.01 - # params.y_step = 0.01 - # - # stats_grid = operational_domain_stats() - # opdomain = operational_domain_grid_search(lyt, [create_and_tt()], params, stats_grid) - # self.assertGreater(stats_grid.num_operational_parameter_combinations, 0) - # - # stats_flood_fill = operational_domain_stats() - # opdomain = operational_domain_flood_fill(lyt, [create_and_tt()], 100, params, stats_flood_fill) - # self.assertGreater(stats_flood_fill.num_operational_parameter_combinations, 0) - # - # stats_random_sampling = operational_domain_stats() - # opdomain = operational_domain_random_sampling(lyt, [create_and_tt()], 100, params, stats_random_sampling) - # self.assertGreater(stats_random_sampling.num_operational_parameter_combinations, 0) - # - # stats_contour_tracing = operational_domain_stats() - # opdomain = operational_domain_contour_tracing(lyt, [create_and_tt()], 100, params, stats_contour_tracing) - # self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) + stats_grid = operational_domain_stats() + opdomain = operational_domain_grid_search(lyt, [create_xor_tt()], params, stats_grid) + self.assertGreater(stats_grid.num_operational_parameter_combinations, 0) + + stats_flood_fill = operational_domain_stats() + opdomain = operational_domain_flood_fill(lyt, [create_xor_tt()], 100, params, stats_flood_fill) + self.assertGreater(stats_flood_fill.num_operational_parameter_combinations, 0) + + stats_random_sampling = operational_domain_stats() + opdomain = operational_domain_random_sampling(lyt, [create_xor_tt()], 100, params, stats_random_sampling) + self.assertGreater(stats_random_sampling.num_operational_parameter_combinations, 0) + + stats_contour_tracing = operational_domain_stats() + opdomain = operational_domain_contour_tracing(lyt, [create_xor_tt()], 100, params, stats_contour_tracing) + self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) + + def test_and_gate_111_lattice(self): + lyt = read_sqd_layout_111(dir_path + "/../../../resources/AND_mu_032_0.sqd") + + params = operational_domain_params() + + params.sim_engine = sidb_simulation_engine.QUICKEXACT + params.simulation_parameters.base = 2 + params.x_dimension = sweep_parameter.EPSILON_R + params.y_dimension = sweep_parameter.LAMBDA_TF + params.x_min = 5.60 + params.x_max = 5.64 + params.x_step = 0.01 + params.y_min = 5.00 + params.y_max = 5.01 + params.y_step = 0.01 + + stats_grid = operational_domain_stats() + opdomain = operational_domain_grid_search(lyt, [create_and_tt()], params, stats_grid) + self.assertGreater(stats_grid.num_operational_parameter_combinations, 0) + + stats_flood_fill = operational_domain_stats() + opdomain = operational_domain_flood_fill(lyt, [create_and_tt()], 100, params, stats_flood_fill) + self.assertGreater(stats_flood_fill.num_operational_parameter_combinations, 0) + + stats_random_sampling = operational_domain_stats() + opdomain = operational_domain_random_sampling(lyt, [create_and_tt()], 100, params, stats_random_sampling) + self.assertGreater(stats_random_sampling.num_operational_parameter_combinations, 0) + + stats_contour_tracing = operational_domain_stats() + opdomain = operational_domain_contour_tracing(lyt, [create_and_tt()], 100, params, stats_contour_tracing) + self.assertGreater(stats_contour_tracing.num_operational_parameter_combinations, 0) if __name__ == '__main__': diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py index 85d79a501..9a9b79981 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_time_to_solution.py @@ -14,33 +14,33 @@ def test_one_sidb_100_lattice(self): tts_params = time_to_solution_params() tts_params.engine = exhaustive_sidb_simulation_engine.QUICKEXACT stats = time_to_solution_stats() - # - # cds = charge_distribution_surface_100(layout) - # - # time_to_solution(cds, quicksim_parameter, tts_params, stats) - # - # self.assertEqual(stats.acc, 100) - # self.assertGreater(stats.time_to_solution, 0.0) - # self.assertGreater(stats.mean_single_runtime, 0.0) - - # def test_one_DBs_111_lattice(self): - # layout = sidb_111_lattice((0, 0)) - # layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) - # - # quicksim_parameter = quicksim_params() - # quicksim_parameter.simulation_parameters = sidb_simulation_parameters(3, -0.3) - # - # tts_params = time_to_solution_params() - # tts_params.engine = exhaustive_sidb_simulation_engine.QUICKEXACT - # stats = time_to_solution_stats() - # - # cds = charge_distribution_surface_111(layout) - # - # time_to_solution(cds, quicksim_parameter, tts_params, stats) - # - # self.assertEqual(stats.acc, 100) - # self.assertGreater(stats.time_to_solution, 0.0) - # self.assertGreater(stats.mean_single_runtime, 0.0) + + cds = charge_distribution_surface_100(layout) + + time_to_solution(cds, quicksim_parameter, tts_params, stats) + + self.assertEqual(stats.acc, 100) + self.assertGreater(stats.time_to_solution, 0.0) + self.assertGreater(stats.mean_single_runtime, 0.0) + + def test_one_DBs_111_lattice(self): + layout = sidb_111_lattice((0, 0)) + layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) + + quicksim_parameter = quicksim_params() + quicksim_parameter.simulation_parameters = sidb_simulation_parameters(3, -0.3) + + tts_params = time_to_solution_params() + tts_params.engine = exhaustive_sidb_simulation_engine.QUICKEXACT + stats = time_to_solution_stats() + + cds = charge_distribution_surface_111(layout) + + time_to_solution(cds, quicksim_parameter, tts_params, stats) + + self.assertEqual(stats.acc, 100) + self.assertGreater(stats.time_to_solution, 0.0) + self.assertGreater(stats.mean_single_runtime, 0.0) if __name__ == '__main__': unittest.main() From 7364f7bcc531774fae053e36bedd8cfd6b32aa51 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 08:52:44 +0200 Subject: [PATCH 36/52] :art: revert changes. --- .../physical_design/design_sidb_gates.hpp | 45 ++++++++----------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp index 46b67bcef..9a5d1696f 100644 --- a/include/fiction/algorithms/physical_design/design_sidb_gates.hpp +++ b/include/fiction/algorithms/physical_design/design_sidb_gates.hpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -119,41 +120,33 @@ class design_sidb_gates_impl [this, &mutex_to_protect_designer_gate_layouts, ¶ms_is_operational, &designed_gate_layouts](const auto& combination) noexcept { - auto layout_with_added_cells = skeleton_layout_with_canvas_sidbs(combination); - if (const auto [status, sim_calls] = - is_operational(layout_with_added_cells, truth_table, params_is_operational); - status == operational_status::OPERATIONAL) + if (!are_sidbs_too_close(combination)) { - const std::lock_guard lock_vector{mutex_to_protect_designer_gate_layouts}; // Lock the mutex - designed_gate_layouts.push_back(layout_with_added_cells); + auto layout_with_added_cells = skeleton_layout_with_canvas_sidbs(combination); + if (const auto [status, sim_calls] = + is_operational(layout_with_added_cells, truth_table, params_is_operational); + status == operational_status::OPERATIONAL) + { + const std::lock_guard lock_vector{mutex_to_protect_designer_gate_layouts}; // Lock the mutex + designed_gate_layouts.push_back(layout_with_added_cells); + } } }; - const std::size_t num_threads = - std::min(static_cast(std::thread::hardware_concurrency()), all_combinations.size()); - const std::size_t chunk_size = (all_combinations.size() + num_threads - 1) / num_threads; // Ceiling division - - std::vector threads; - threads.reserve(num_threads); + std::vector> futures{}; + futures.reserve(all_combinations.size()); - for (std::size_t i = 0; i < num_threads; ++i) + // Start asynchronous tasks to process combinations in parallel + for (const auto& combination : all_combinations) { - threads.emplace_back( - [i, chunk_size, &all_combinations, &add_combination_to_layout_and_check_operation]() - { - std::size_t start_index = i * chunk_size; - std::size_t end_index = std::min(start_index + chunk_size, all_combinations.size()); - - for (std::size_t j = start_index; j < end_index; ++j) - { - add_combination_to_layout_and_check_operation(all_combinations[j]); - } - }); + futures.emplace_back( + std::async(std::launch::async, add_combination_to_layout_and_check_operation, combination)); } - for (auto& thread : threads) + // Wait for all tasks to finish + for (auto& future : futures) { - thread.join(); + future.wait(); } return designed_gate_layouts; From ea54c9d2a65b0243d86d3ffb439762541f708c89 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 09:09:37 +0200 Subject: [PATCH 37/52] :art: using old quicksim code --- .../algorithms/simulation/sidb/quicksim.hpp | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/include/fiction/algorithms/simulation/sidb/quicksim.hpp b/include/fiction/algorithms/simulation/sidb/quicksim.hpp index cee45d43a..beb3ec8a0 100644 --- a/include/fiction/algorithms/simulation/sidb/quicksim.hpp +++ b/include/fiction/algorithms/simulation/sidb/quicksim.hpp @@ -15,8 +15,8 @@ #include #include -#include #include +#include #include namespace fiction @@ -77,7 +77,6 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = st.charge_distributions.reserve(ps.iteration_steps); mockturtle::stopwatch<>::duration time_counter{}; - std::mutex mutex{}; // measure run time (artificial scope) { @@ -134,14 +133,14 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = uint64_t{1}); // If the number of set threads is greater than the number of iterations, the // number of threads defines how many times QuickSim is repeated - std::vector> futures; - futures.reserve(num_threads); + std::vector threads{}; + threads.reserve(num_threads); + std::mutex mutex{}; // used to control access to shared resources for (uint64_t z = 0ul; z < num_threads; z++) { - futures.emplace_back(std::async( - std::launch::async, - [&st, &charge_lyt, negative_sidb_indices, iter_per_thread, ps, num_threads, &mutex] + threads.emplace_back( + [&] { charge_distribution_surface charge_lyt_copy{charge_lyt}; @@ -149,10 +148,13 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = { for (uint64_t i = 0ul; i < charge_lyt.num_cells(); ++i) { - if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != - negative_sidb_indices.cend()) { - continue; + const std::lock_guard lock{mutex}; + if (std::find(negative_sidb_indices.cbegin(), negative_sidb_indices.cend(), i) != + negative_sidb_indices.cend()) + { + continue; + } } std::vector index_start{i}; @@ -171,12 +173,12 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = if (charge_lyt_copy.is_physically_valid()) { - const std::lock_guard lock{mutex}; + const std::lock_guard lock{mutex}; st.charge_distributions.push_back(charge_distribution_surface{charge_lyt_copy}); } const auto upper_limit = - std::min(static_cast(static_cast(charge_lyt_copy.num_cells())), + std::min(static_cast(static_cast(charge_lyt_copy.num_cells()) / 1.5), charge_lyt.num_cells() - negative_sidb_indices.size()); for (uint64_t num = 0ul; num < upper_limit; num++) @@ -186,19 +188,19 @@ sidb_simulation_result quicksim(const Lyt& lyt, const quicksim_params& ps = if (charge_lyt_copy.is_physically_valid()) { - const std::lock_guard lock{mutex}; + const std::lock_guard lock{mutex}; st.charge_distributions.push_back( charge_distribution_surface{charge_lyt_copy}); } } } } - })); + }); } - for (auto& future : futures) + for (auto& thread : threads) { - future.get(); + thread.join(); } } From 95dd32d7f1a780dc7aa109c93fdafd6533bae562 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 09:12:05 +0200 Subject: [PATCH 38/52] :green_heart: use windows-2019. --- .github/workflows/pyfiction-pypi-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyfiction-pypi-deployment.yml b/.github/workflows/pyfiction-pypi-deployment.yml index 25124cdec..642fc3fe7 100644 --- a/.github/workflows/pyfiction-pypi-deployment.yml +++ b/.github/workflows/pyfiction-pypi-deployment.yml @@ -53,7 +53,7 @@ jobs: - { os: ubuntu-latest, arch: x64 } - { os: macos-latest, arch: x64 } - { os: macos-latest, arch: arm64 } - - { os: windows-latest, arch: x64 } + - { os: windows-2019, arch: x64 } python: ['cp38', 'cp39', 'cp310', 'cp311', 'cp312'] steps: - uses: actions/checkout@v4 From b377ecae619212f28e2ee8491790f2f026c6f68d Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 09:22:38 +0200 Subject: [PATCH 39/52] :green_heart: revert code changes. --- .../algorithms/simulation/sidb/quicksim.hpp | 4 +++- .../simulation/sidb/test_quicksim.py | 23 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp index 5b4ed5bd6..291641e67 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp @@ -42,7 +42,9 @@ inline void quicksim(pybind11::module& m) DOC(fiction_quicksim_params_simulation_parameters)) .def_readwrite("iteration_steps", &fiction::quicksim_params::iteration_steps, DOC(fiction_quicksim_params_iteration_steps)) - .def_readwrite("alpha", &fiction::quicksim_params::alpha, DOC(fiction_quicksim_params_alpha)); + .def_readwrite("alpha", &fiction::quicksim_params::alpha, DOC(fiction_quicksim_params_alpha)) + .def_readwrite("number_threads", &fiction::quicksim_params::number_threads, + DOC(fiction_quicksim_params_number_threads)); // NOTE be careful with the order of the following calls! Python will resolve the first matching overload! diff --git a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py index 53067d82c..2793cf84c 100644 --- a/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py +++ b/bindings/pyfiction/test/algorithms/simulation/sidb/test_quicksim.py @@ -10,7 +10,7 @@ def test_perturber_and_sidb_pair(self): layout.assign_cell_type((0, 1), sidb_technology.cell_type.NORMAL) layout.assign_cell_type((4, 1), sidb_technology.cell_type.NORMAL) layout.assign_cell_type((6, 1), sidb_technology.cell_type.NORMAL) - # + params = quicksim_params() params.simulation_parameters = sidb_simulation_parameters() params.iteration_steps = 80 @@ -21,16 +21,15 @@ def test_perturber_and_sidb_pair(self): params_one = quicksim_params() params_one.iteration_steps = 50 params_one.alpha = 0.4 - + params_one.number_threads = 1 self.assertEqual(params_one.iteration_steps, 50) self.assertEqual(params_one.alpha, 0.4) + self.assertEqual(params_one.number_threads, 1) cds = charge_distribution_surface(layout) result = quicksim(layout, params) - print("len: " + str(len(result.charge_distributions))) - self.assertEqual(result.algorithm_name, "QuickSim") self.assertLessEqual(len(result.charge_distributions), 80) @@ -39,13 +38,13 @@ def test_perturber_and_sidb_pair(self): self.assertEqual(groundstate.get_charge_state((0, 1)), sidb_charge_state.NEGATIVE) self.assertEqual(groundstate.get_charge_state((4, 1)), sidb_charge_state.NEUTRAL) self.assertEqual(groundstate.get_charge_state((6, 1)), sidb_charge_state.NEGATIVE) - # + def test_perturber_and_sidb_pair_111(self): - layout_111 = sidb_111_lattice((4, 1)) - layout_111.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) - layout_111.assign_cell_type((1, 0), sidb_technology.cell_type.NORMAL) - layout_111.assign_cell_type((2, 0), sidb_technology.cell_type.NORMAL) - layout_111.assign_cell_type((3, 0), sidb_technology.cell_type.NORMAL) + layout = sidb_111_lattice((4, 1)) + layout.assign_cell_type((0, 0), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((1, 0), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((2, 0), sidb_technology.cell_type.NORMAL) + layout.assign_cell_type((3, 0), sidb_technology.cell_type.NORMAL) params = quicksim_params() params.simulation_parameters = sidb_simulation_parameters() @@ -56,9 +55,9 @@ def test_perturber_and_sidb_pair_111(self): self.assertEqual(params.alpha, 0.7) self.assertEqual(params.simulation_parameters.mu_minus, -0.32) - cds = charge_distribution_surface_111(layout_111) + cds = charge_distribution_surface_111(layout) - result = quicksim(cds, params) + result = quicksim(layout, params) self.assertEqual(result.algorithm_name, "QuickSim") From dd64d5b6a41f51889a3f917a2e440bdcff9c0a76 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 09:34:25 +0200 Subject: [PATCH 40/52] :green_heart: using windows-2019. --- .github/workflows/python-bindings.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 787b34c43..8ae151374 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -44,7 +44,7 @@ jobs: build_and_test: strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ ubuntu-latest, macos-latest, windows-2019 ] python_version: [ '3.8.x', '3.12.x' ] include: - os: ubuntu-latest @@ -53,7 +53,7 @@ jobs: - os: macos-latest z3_platform: macOS architecture: arm64 - - os: windows-latest + - os: windows-2019 z3_platform: windows architecture: x64 From f0a2c4740629558bd80cf2519662c702e00f9d84 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 10:23:45 +0200 Subject: [PATCH 41/52] :green_heart: remove ``*-latest`` and use toolsets. --- .github/workflows/python-bindings.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 8ae151374..8e5f86c4e 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -44,18 +44,23 @@ jobs: build_and_test: strategy: matrix: - os: [ ubuntu-latest, macos-latest, windows-2019 ] + os: [ ubuntu-22.04, macos-14, windows-2022 ] + toolset: [ v142, v143] python_version: [ '3.8.x', '3.12.x' ] include: - - os: ubuntu-latest + - os: ubuntu-22.04 z3_platform: linux architecture: x64 - - os: macos-latest + - os: macos-14 z3_platform: macOS architecture: arm64 - - os: windows-2019 + - os: windows-2022 z3_platform: windows architecture: x64 + exclude: + - os: windows-2022 + toolset: v144 + name: 🐍 on ${{matrix.os}} with Python ${{matrix.python_version}} runs-on: ${{matrix.os}} From b178e8917c5b7899893639f72b2b0db7ad38b0f4 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 10:33:03 +0200 Subject: [PATCH 42/52] :green_heart: use toolsets. --- .github/workflows/python-bindings.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 8e5f86c4e..e47b6b4dd 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -62,7 +62,7 @@ jobs: toolset: v144 - name: 🐍 on ${{matrix.os}} with Python ${{matrix.python_version}} + name: 🐍 on ${{matrix.os}} and ${{matrix.toolset}} toolset with Python ${{matrix.python_version}} runs-on: ${{matrix.os}} steps: @@ -74,7 +74,7 @@ jobs: - name: Setup ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: '${{matrix.os}}-pyfiction' + key: '${{matrix.os}}-${{matrix.toolset}}-pyfiction' variant: ccache save: true max-size: 10G From aa694c4d04681f11b50acf4ae528476f4c20db38 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 10:46:22 +0200 Subject: [PATCH 43/52] :green_heart: update toolsets. --- .github/workflows/python-bindings.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index e47b6b4dd..fd9d80a3e 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -45,7 +45,6 @@ jobs: strategy: matrix: os: [ ubuntu-22.04, macos-14, windows-2022 ] - toolset: [ v142, v143] python_version: [ '3.8.x', '3.12.x' ] include: - os: ubuntu-22.04 @@ -57,6 +56,11 @@ jobs: - os: windows-2022 z3_platform: windows architecture: x64 + toolset: v142 + - os: windows-2022 + z3_platform: windows + architecture: x64 + toolset: v143 exclude: - os: windows-2022 toolset: v144 From fa336e5b7789cb4e0b1d5fc1ce7b31c2915af255 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 10:55:20 +0200 Subject: [PATCH 44/52] :green_heart: delete exclude part. --- .github/workflows/python-bindings.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index fd9d80a3e..782f45887 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -61,9 +61,6 @@ jobs: z3_platform: windows architecture: x64 toolset: v143 - exclude: - - os: windows-2022 - toolset: v144 name: 🐍 on ${{matrix.os}} and ${{matrix.toolset}} toolset with Python ${{matrix.python_version}} From 808f9e8749b0429a566cfa2798b9248fcb7907ae Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 11:03:58 +0200 Subject: [PATCH 45/52] :green_heart: windows 2019. --- .github/workflows/python-bindings.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 782f45887..1be403445 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -44,26 +44,26 @@ jobs: build_and_test: strategy: matrix: - os: [ ubuntu-22.04, macos-14, windows-2022 ] + os: [ ubuntu-22.04, macos-14, windows-2019 ] python_version: [ '3.8.x', '3.12.x' ] include: - os: ubuntu-22.04 z3_platform: linux architecture: x64 + toolset: v142 - os: macos-14 z3_platform: macOS architecture: arm64 - - os: windows-2022 + - os: windows-2019 z3_platform: windows architecture: x64 toolset: v142 - - os: windows-2022 + - os: windows-2019 z3_platform: windows architecture: x64 toolset: v143 - - name: 🐍 on ${{matrix.os}} and ${{matrix.toolset}} toolset with Python ${{matrix.python_version}} + name: 🐍 on ${{matrix.os}} with Python ${{matrix.python_version}} runs-on: ${{matrix.os}} steps: From b44f7a95331a0687861c3ed076e05c9c67be2c78 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 11:11:34 +0200 Subject: [PATCH 46/52] :green_heart: remove toolset key. --- .github/workflows/python-bindings.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 1be403445..cf8f8fe96 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -75,7 +75,7 @@ jobs: - name: Setup ccache uses: hendrikmuhs/ccache-action@v1.2 with: - key: '${{matrix.os}}-${{matrix.toolset}}-pyfiction' + key: '${{matrix.os}}-pyfiction' variant: ccache save: true max-size: 10G From 369b987a7bb89d95d8de324695fa61bba77e3c0e Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 11:15:09 +0200 Subject: [PATCH 47/52] :green_heart: use v143 for 2022. --- .github/workflows/python-bindings.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index cf8f8fe96..794838c78 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -44,7 +44,7 @@ jobs: build_and_test: strategy: matrix: - os: [ ubuntu-22.04, macos-14, windows-2019 ] + os: [ ubuntu-22.04, macos-14, windows-2022 ] python_version: [ '3.8.x', '3.12.x' ] include: - os: ubuntu-22.04 @@ -54,11 +54,7 @@ jobs: - os: macos-14 z3_platform: macOS architecture: arm64 - - os: windows-2019 - z3_platform: windows - architecture: x64 - toolset: v142 - - os: windows-2019 + - os: windows-2022 z3_platform: windows architecture: x64 toolset: v143 From 816ad08ad783e51d99c202501f9e8442323592d2 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 11:17:53 +0200 Subject: [PATCH 48/52] :green_heart: use v143 for 2022. --- .github/workflows/pyfiction-pypi-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyfiction-pypi-deployment.yml b/.github/workflows/pyfiction-pypi-deployment.yml index 642fc3fe7..6cc2a24b4 100644 --- a/.github/workflows/pyfiction-pypi-deployment.yml +++ b/.github/workflows/pyfiction-pypi-deployment.yml @@ -53,7 +53,7 @@ jobs: - { os: ubuntu-latest, arch: x64 } - { os: macos-latest, arch: x64 } - { os: macos-latest, arch: arm64 } - - { os: windows-2019, arch: x64 } + - { os: windows-2012, arch: x64, toolset: v143 } python: ['cp38', 'cp39', 'cp310', 'cp311', 'cp312'] steps: - uses: actions/checkout@v4 From 01dc07f350e53ec91451f7a381511822b07e75b9 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 11:18:04 +0200 Subject: [PATCH 49/52] :green_heart: use v143 for 2022. --- .github/workflows/pyfiction-pypi-deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pyfiction-pypi-deployment.yml b/.github/workflows/pyfiction-pypi-deployment.yml index 6cc2a24b4..a4c338e23 100644 --- a/.github/workflows/pyfiction-pypi-deployment.yml +++ b/.github/workflows/pyfiction-pypi-deployment.yml @@ -53,7 +53,7 @@ jobs: - { os: ubuntu-latest, arch: x64 } - { os: macos-latest, arch: x64 } - { os: macos-latest, arch: arm64 } - - { os: windows-2012, arch: x64, toolset: v143 } + - { os: windows-2022, arch: x64, toolset: v143 } python: ['cp38', 'cp39', 'cp310', 'cp311', 'cp312'] steps: - uses: actions/checkout@v4 From 2581a43a2e62cbd4f32f7da14fadaf12a858dec5 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 12:12:50 +0200 Subject: [PATCH 50/52] :green_heart: use 2019. --- .github/workflows/pyfiction-pypi-deployment.yml | 2 +- .github/workflows/python-bindings.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pyfiction-pypi-deployment.yml b/.github/workflows/pyfiction-pypi-deployment.yml index a4c338e23..4f1dc93a7 100644 --- a/.github/workflows/pyfiction-pypi-deployment.yml +++ b/.github/workflows/pyfiction-pypi-deployment.yml @@ -53,7 +53,7 @@ jobs: - { os: ubuntu-latest, arch: x64 } - { os: macos-latest, arch: x64 } - { os: macos-latest, arch: arm64 } - - { os: windows-2022, arch: x64, toolset: v143 } + - { os: windows-2022, arch: x64} python: ['cp38', 'cp39', 'cp310', 'cp311', 'cp312'] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index 794838c78..cbead9d3a 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -44,7 +44,7 @@ jobs: build_and_test: strategy: matrix: - os: [ ubuntu-22.04, macos-14, windows-2022 ] + os: [ ubuntu-22.04, macos-14, windows-2019 ] python_version: [ '3.8.x', '3.12.x' ] include: - os: ubuntu-22.04 @@ -54,7 +54,7 @@ jobs: - os: macos-14 z3_platform: macOS architecture: arm64 - - os: windows-2022 + - os: windows-2019 z3_platform: windows architecture: x64 toolset: v143 From bfc5a301a5dc9697c547ec128ac45e42953510b7 Mon Sep 17 00:00:00 2001 From: Drewniok Date: Thu, 27 Jun 2024 12:17:12 +0200 Subject: [PATCH 51/52] :green_heart only using 2019. --- .github/workflows/pyfiction-pypi-deployment.yml | 2 +- .github/workflows/python-bindings.yml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pyfiction-pypi-deployment.yml b/.github/workflows/pyfiction-pypi-deployment.yml index 4f1dc93a7..a1f9f6a09 100644 --- a/.github/workflows/pyfiction-pypi-deployment.yml +++ b/.github/workflows/pyfiction-pypi-deployment.yml @@ -53,7 +53,7 @@ jobs: - { os: ubuntu-latest, arch: x64 } - { os: macos-latest, arch: x64 } - { os: macos-latest, arch: arm64 } - - { os: windows-2022, arch: x64} + - { os: windows-2019, arch: x64} python: ['cp38', 'cp39', 'cp310', 'cp311', 'cp312'] steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/python-bindings.yml b/.github/workflows/python-bindings.yml index cbead9d3a..8f0203685 100644 --- a/.github/workflows/python-bindings.yml +++ b/.github/workflows/python-bindings.yml @@ -57,7 +57,6 @@ jobs: - os: windows-2019 z3_platform: windows architecture: x64 - toolset: v143 name: 🐍 on ${{matrix.os}} with Python ${{matrix.python_version}} runs-on: ${{matrix.os}} From 71560f15c00ed982f258b92a453454297c300d0a Mon Sep 17 00:00:00 2001 From: Drewniok Date: Fri, 28 Jun 2024 07:36:33 +0200 Subject: [PATCH 52/52] :art: implement Marcel's comments. --- .github/workflows/pyfiction-pypi-deployment.yml | 8 ++++---- .../pyfiction/algorithms/simulation/sidb/quicksim.hpp | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pyfiction-pypi-deployment.yml b/.github/workflows/pyfiction-pypi-deployment.yml index a1f9f6a09..1b88d5a11 100644 --- a/.github/workflows/pyfiction-pypi-deployment.yml +++ b/.github/workflows/pyfiction-pypi-deployment.yml @@ -50,10 +50,10 @@ jobs: fail-fast: false matrix: config: - - { os: ubuntu-latest, arch: x64 } - - { os: macos-latest, arch: x64 } - - { os: macos-latest, arch: arm64 } - - { os: windows-2019, arch: x64} + - { os: ubuntu-22.04, arch: x64 } + - { os: macos-13, arch: x64 } + - { os: macos-14, arch: arm64 } + - { os: windows-2019, arch: x64 } python: ['cp38', 'cp39', 'cp310', 'cp311', 'cp312'] steps: - uses: actions/checkout@v4 diff --git a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp index 291641e67..a01c00f27 100644 --- a/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp +++ b/bindings/pyfiction/include/pyfiction/algorithms/simulation/sidb/quicksim.hpp @@ -44,7 +44,9 @@ inline void quicksim(pybind11::module& m) DOC(fiction_quicksim_params_iteration_steps)) .def_readwrite("alpha", &fiction::quicksim_params::alpha, DOC(fiction_quicksim_params_alpha)) .def_readwrite("number_threads", &fiction::quicksim_params::number_threads, - DOC(fiction_quicksim_params_number_threads)); + DOC(fiction_quicksim_params_number_threads)) + + ; // NOTE be careful with the order of the following calls! Python will resolve the first matching overload!