From 88c0b58305ab36ba87c5623414f2e11666342e8c Mon Sep 17 00:00:00 2001 From: Lane Date: Tue, 12 Sep 2023 21:02:47 -0500 Subject: [PATCH] remove unnecessary data passing with thread IDs in the core worksharing schedulers --- DotMP/Iter.cs | 17 ++++++----------- DotMP/Parallel.cs | 8 ++++---- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/DotMP/Iter.cs b/DotMP/Iter.cs index 63b0b246..e691459d 100644 --- a/DotMP/Iter.cs +++ b/DotMP/Iter.cs @@ -33,9 +33,9 @@ internal static class Iter /// The function to be executed. /// The function to be executed for reductions. /// Whether or not the loop is a reduction loop. - internal static void StaticLoop(WorkShare ws, object thread_id, Action omp_fn, ActionRef omp_fn_red, bool is_reduction) + internal static void StaticLoop(WorkShare ws, int thread_id, Action omp_fn, ActionRef omp_fn_red, bool is_reduction) { - int tid = (int)thread_id; + int tid = thread_id; Thr thr = ws.thread; thr.curr_iter = (int)(ws.start + tid * ws.chunk_size); @@ -45,7 +45,7 @@ internal static void StaticLoop(WorkShare ws, object thread_id, Action o ws.SetLocal(ref local); while (thr.curr_iter < end) - StaticNext(ws, thr, tid, ws.chunk_size, omp_fn, omp_fn_red, is_reduction, ref local); + StaticNext(ws, thr, ws.chunk_size, omp_fn, omp_fn_red, is_reduction, ref local); ws.Finished(); @@ -59,13 +59,12 @@ internal static void StaticLoop(WorkShare ws, object thread_id, Action o /// The type of the local variable for reductions. /// The WorkShare object for state. /// The Thr object for the current thread. - /// The thread ID. /// The chunk size. /// The function to be executed. /// The function to be executed for reductions. /// Whether or not the loop is a reduction loop. /// The local variable for reductions. - private static void StaticNext(WorkShare ws, Thr thr, int thread_id, uint chunk_size, Action omp_fn, ActionRef omp_fn_red, bool is_reduction, ref T local) + private static void StaticNext(WorkShare ws, Thr thr, uint chunk_size, Action omp_fn, ActionRef omp_fn_red, bool is_reduction, ref T local) { int start = thr.curr_iter; int end = (int)Math.Min(thr.curr_iter + chunk_size, ws.end); @@ -98,13 +97,11 @@ private static void StaticNext(WorkShare ws, Thr thr, int thread_id, uint chu /// /// The type of the local variable for reductions. /// The WorkShare object for state. - /// The thread ID. /// The function to be executed. /// The function to be executed for reductions. /// Whether or not the loop is a reduction loop. - internal static void DynamicLoop(WorkShare ws, object thread_id, Action omp_fn, ActionRef omp_fn_red, bool is_reduction) + internal static void DynamicLoop(WorkShare ws, Action omp_fn, ActionRef omp_fn_red, bool is_reduction) { - int tid = (int)thread_id; Thr thr = ws.thread; int end = ws.end; @@ -173,13 +170,11 @@ private static void DynamicNext(WorkShare ws, Thr thr, Action omp_fn, Ac /// /// The type of the local variable for reductions. /// The WorkShare object for state. - /// The thread ID. /// The function to be executed. /// The function to be executed for reductions. /// Whether or not the loop is a reduction loop. - internal static void GuidedLoop(WorkShare ws, object thread_id, Action omp_fn, ActionRef omp_fn_red, bool is_reduction) + internal static void GuidedLoop(WorkShare ws, Action omp_fn, ActionRef omp_fn_red, bool is_reduction) { - int tid = (int)thread_id; Thr thr = ws.thread; int end = ws.end; diff --git a/DotMP/Parallel.cs b/DotMP/Parallel.cs index 5721a017..0c2313fa 100644 --- a/DotMP/Parallel.cs +++ b/DotMP/Parallel.cs @@ -161,10 +161,10 @@ public static void For(int start, int end, Action action, Schedule schedule Iter.StaticLoop(ws, GetThreadNum(), action, null, false); break; case Schedule.Dynamic: - Iter.DynamicLoop(ws, GetThreadNum(), action, null, false); + Iter.DynamicLoop(ws, action, null, false); break; case Schedule.Guided: - Iter.GuidedLoop(ws, GetThreadNum(), action, null, false); + Iter.GuidedLoop(ws, action, null, false); break; } @@ -219,10 +219,10 @@ public static void ForReduction(int start, int end, Operations op, ref T redu Iter.StaticLoop(ws, GetThreadNum(), null, action, true); break; case Schedule.Dynamic: - Iter.DynamicLoop(ws, GetThreadNum(), null, action, true); + Iter.DynamicLoop(ws, null, action, true); break; case Schedule.Guided: - Iter.GuidedLoop(ws, GetThreadNum(), null, action, true); + Iter.GuidedLoop(ws, null, action, true); break; }