Skip to content

Commit

Permalink
parallelizing sorting, pass 2
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaller committed Aug 12, 2023
1 parent b310254 commit bb72a18
Show file tree
Hide file tree
Showing 10 changed files with 447 additions and 203 deletions.
38 changes: 20 additions & 18 deletions SLiM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,14 @@
986D73E81B07E89E007FBB70 /* eidos_call_signature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 986D73E61B07E89E007FBB70 /* eidos_call_signature.cpp */; };
986D73E91B07E89E007FBB70 /* eidos_call_signature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 986D73E61B07E89E007FBB70 /* eidos_call_signature.cpp */; };
986D73EA1B07E89E007FBB70 /* eidos_call_signature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 986D73E61B07E89E007FBB70 /* eidos_call_signature.cpp */; };
98729ACF2A87AAB700E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */; };
98729AD02A87AAB700E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */; };
98729AD12A87AAB700E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */; };
98729AD22A87AAB700E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */; };
98729AD32A87AAB700E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */; };
98729AD42A87AAB700E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */; };
98729AD52A87AAB700E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */; };
98729AD62A87AAB700E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */; };
98729AD82A87DFBE00E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */; };
98729AD92A87DFBE00E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */; };
98729ADA2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */; };
98729ADB2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */; };
98729ADC2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */; };
98729ADD2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */; };
98729ADE2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */; };
98729ADF2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */; };
98760EDD28CE5E7600CEBC40 /* libomp.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 98760EDC28CE5E7600CEBC40 /* libomp.dylib */; };
98760EDE28CE5E8200CEBC40 /* libomp.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 98760EDC28CE5E7600CEBC40 /* libomp.dylib */; };
9876E5F51ED5572C00FF9762 /* tdist.c in Sources */ = {isa = PBXBuildFile; fileRef = 9876E5F41ED5572C00FF9762 /* tdist.c */; };
Expand Down Expand Up @@ -1627,7 +1627,8 @@
986D73E61B07E89E007FBB70 /* eidos_call_signature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = eidos_call_signature.cpp; sourceTree = "<group>"; };
986D73E71B07E89E007FBB70 /* eidos_call_signature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = eidos_call_signature.h; sourceTree = "<group>"; };
98729ACD2A87A93500E81662 /* eidos_sorting.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = eidos_sorting.h; sourceTree = "<group>"; };
98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = eidos_sorting.cpp; sourceTree = "<group>"; };
98729ACE2A87AAB700E81662 /* eidos_sorting.inc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.pascal; path = eidos_sorting.inc; sourceTree = "<group>"; };
98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = eidos_sorting.cpp; sourceTree = "<group>"; };
9873B12328CE26CD00582D83 /* eidos_openmp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = eidos_openmp.h; sourceTree = "<group>"; };
98760EDC28CE5E7600CEBC40 /* libomp.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libomp.dylib; path = /usr/local/lib/libomp.dylib; sourceTree = "<group>"; };
9876E5F31ED5572C00FF9762 /* gsl_cdf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gsl_cdf.h; path = cdf/gsl_cdf.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2020,7 +2021,8 @@
985A11861BBA07CB009EE1FF /* eidos_object_pool.h */,
9809F8BD24F32B3E00D312E4 /* eidos_tinycolormap.h */,
98729ACD2A87A93500E81662 /* eidos_sorting.h */,
98729ACE2A87AAB700E81662 /* eidos_sorting.cpp */,
98729AD72A87DFBE00E81662 /* eidos_sorting.cpp */,
98729ACE2A87AAB700E81662 /* eidos_sorting.inc */,
9893C7DC1CDA2D650029AC94 /* eidos_beep.h */,
9893C7DB1CDA2D650029AC94 /* eidos_beep.cpp */,
98B8AF8725A2BE7200C95D66 /* json_fwd.hpp */,
Expand Down Expand Up @@ -3312,7 +3314,7 @@
982556B81BA8EF8C0054CB3F /* eidos_property_signature.cpp in Sources */,
98C8217F1C7A983800548839 /* inline.c in Sources */,
985F3F0E24BA31D900E712E0 /* eidos_test_functions_statistics.cpp in Sources */,
98729AD42A87AAB700E81662 /* eidos_sorting.cpp in Sources */,
98729ADD2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */,
98C821AC1C7A9B1600548839 /* discrete.c in Sources */,
9807663924493E0B00F6CBB4 /* gzwrite.c in Sources */,
98C8218C1C7A983800548839 /* poisson.c in Sources */,
Expand Down Expand Up @@ -3384,7 +3386,7 @@
98332ADC1FDBC0D000274FF0 /* dgemv.c in Sources */,
98332B111FDBD09800274FF0 /* init.c in Sources */,
98C8212C1C7A980000548839 /* gamma.c in Sources */,
98729ACF2A87AAB700E81662 /* eidos_sorting.cpp in Sources */,
98729AD82A87DFBE00E81662 /* eidos_sorting.cpp in Sources */,
98C8212D1C7A980000548839 /* gauss.c in Sources */,
985F3F0124BA307200E712E0 /* eidos_test_operators_arithmetic.cpp in Sources */,
985F3F0B24BA31D900E712E0 /* eidos_test_functions_statistics.cpp in Sources */,
Expand Down Expand Up @@ -3627,7 +3629,7 @@
98332AEE1FDBC29500274FF0 /* rowcol.c in Sources */,
9890D1EF27136BB7001EAE98 /* eidos_class_DataFrame.cpp in Sources */,
987AD8871B2CC0C10035D6C8 /* EidosVariableBrowserController.mm in Sources */,
98729AD22A87AAB700E81662 /* eidos_sorting.cpp in Sources */,
98729ADB2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */,
9807662B24493E0B00F6CBB4 /* crc32.c in Sources */,
98C821661C7A983800548839 /* beta.c in Sources */,
985F3EFE24BA2F1500E712E0 /* eidos_test_functions_vector.cpp in Sources */,
Expand Down Expand Up @@ -3706,7 +3708,7 @@
98CF5215294A3FC900557BBA /* binomial_tpe.c in Sources */,
98CF5216294A3FC900557BBA /* tables.c in Sources */,
98CF5217294A3FC900557BBA /* species_eidos.cpp in Sources */,
98729AD12A87AAB700E81662 /* eidos_sorting.cpp in Sources */,
98729ADA2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */,
98CF5218294A3FC900557BBA /* slim_functions.cpp in Sources */,
98CF5219294A3FC900557BBA /* deflate.c in Sources */,
98CF521A294A3FC900557BBA /* FindRecipeController.mm in Sources */,
Expand Down Expand Up @@ -3934,7 +3936,7 @@
98CF53E8294A714200557BBA /* rowcol.c in Sources */,
98CF53E9294A714200557BBA /* eidos_class_DataFrame.cpp in Sources */,
98CF53EA294A714200557BBA /* EidosVariableBrowserController.mm in Sources */,
98729AD32A87AAB700E81662 /* eidos_sorting.cpp in Sources */,
98729ADC2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */,
98CF53EB294A714200557BBA /* crc32.c in Sources */,
98CF53EC294A714200557BBA /* beta.c in Sources */,
98CF53ED294A714200557BBA /* eidos_test_functions_vector.cpp in Sources */,
Expand Down Expand Up @@ -4013,7 +4015,7 @@
98C821491C7A983700548839 /* binomial_tpe.c in Sources */,
9850D8E9206309A0006BFD2E /* tables.c in Sources */,
98AC617B24BA34ED0001914C /* species_eidos.cpp in Sources */,
98729AD02A87AAB700E81662 /* eidos_sorting.cpp in Sources */,
98729AD92A87DFBE00E81662 /* eidos_sorting.cpp in Sources */,
98DDAED7221765480038C133 /* slim_functions.cpp in Sources */,
98076618244934A800F6CBB4 /* deflate.c in Sources */,
984252C3216FA9930019696A /* FindRecipeController.mm in Sources */,
Expand Down Expand Up @@ -4210,7 +4212,7 @@
98D7EBB328CE557C00DEAAC4 /* poisson.c in Sources */,
98D7EBB428CE557C00DEAAC4 /* eidos_type_table.cpp in Sources */,
98D7EBB528CE557C00DEAAC4 /* exp.c in Sources */,
98729AD52A87AAB700E81662 /* eidos_sorting.cpp in Sources */,
98729ADE2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */,
98D7EBB628CE557C00DEAAC4 /* eidos_test_functions_other.cpp in Sources */,
98D7EBB728CE557C00DEAAC4 /* eidos_script.cpp in Sources */,
981DC37B28E27300000ABE91 /* eidos_functions_distributions.cpp in Sources */,
Expand Down Expand Up @@ -4282,7 +4284,7 @@
98D7ECA428CE58FC00DEAAC4 /* dgemv.c in Sources */,
98D7ECA528CE58FC00DEAAC4 /* init.c in Sources */,
98D7ECA628CE58FC00DEAAC4 /* gamma.c in Sources */,
98729AD62A87AAB700E81662 /* eidos_sorting.cpp in Sources */,
98729ADF2A87DFBE00E81662 /* eidos_sorting.cpp in Sources */,
98D7ECA728CE58FC00DEAAC4 /* gauss.c in Sources */,
98D7ECA828CE58FC00DEAAC4 /* eidos_test_operators_arithmetic.cpp in Sources */,
981DC38528E27301000ABE91 /* eidos_functions_files.cpp in Sources */,
Expand Down
8 changes: 8 additions & 0 deletions eidos/eidos_functions_other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,10 @@ EidosValue_SP Eidos_ExecuteFunction_parallelGetTaskThreadCounts(__attribute__((u
objectElement->SetKeyValue_StringKeys("RUNIF_2", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RUNIF_2)));
objectElement->SetKeyValue_StringKeys("RUNIF_3", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_RUNIF_3)));

objectElement->SetKeyValue_StringKeys("SORT_INT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SORT_INT)));
objectElement->SetKeyValue_StringKeys("SORT_FLOAT", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SORT_FLOAT)));
objectElement->SetKeyValue_StringKeys("SORT_STRING", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_SORT_STRING)));

objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_1D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_IN_BOUNDS_1D)));
objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_2D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_IN_BOUNDS_2D)));
objectElement->SetKeyValue_StringKeys("POINT_IN_BOUNDS_3D", EidosValue_SP(new (gEidosValuePool->AllocateChunk()) EidosValue_Int_singleton(gEidos_OMP_threads_POINT_IN_BOUNDS_3D)));
Expand Down Expand Up @@ -999,6 +1003,10 @@ EidosValue_SP Eidos_ExecuteFunction_parallelSetTaskThreadCounts(__attribute__((u
else if (key == "RUNIF_2") gEidos_OMP_threads_RUNIF_2 = (int)value_int64;
else if (key == "RUNIF_3") gEidos_OMP_threads_RUNIF_3 = (int)value_int64;

else if (key == "SORT_INT") gEidos_OMP_threads_SORT_INT = (int)value_int64;
else if (key == "SORT_FLOAT") gEidos_OMP_threads_SORT_FLOAT = (int)value_int64;
else if (key == "SORT_STRING") gEidos_OMP_threads_SORT_STRING = (int)value_int64;

else if (key == "POINT_IN_BOUNDS_1D") gEidos_OMP_threads_POINT_IN_BOUNDS_1D = (int)value_int64;
else if (key == "POINT_IN_BOUNDS_2D") gEidos_OMP_threads_POINT_IN_BOUNDS_2D = (int)value_int64;
else if (key == "POINT_IN_BOUNDS_3D") gEidos_OMP_threads_POINT_IN_BOUNDS_3D = (int)value_int64;
Expand Down
20 changes: 20 additions & 0 deletions eidos/eidos_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ int gEidos_OMP_threads_RUNIF_1 = EIDOS_OMP_MAX_THREADS;
int gEidos_OMP_threads_RUNIF_2 = EIDOS_OMP_MAX_THREADS;
int gEidos_OMP_threads_RUNIF_3 = EIDOS_OMP_MAX_THREADS;

int gEidos_OMP_threads_SORT_INT = EIDOS_OMP_MAX_THREADS;
int gEidos_OMP_threads_SORT_FLOAT = EIDOS_OMP_MAX_THREADS;
int gEidos_OMP_threads_SORT_STRING = EIDOS_OMP_MAX_THREADS;

int gEidos_OMP_threads_POINT_IN_BOUNDS_1D = EIDOS_OMP_MAX_THREADS;
int gEidos_OMP_threads_POINT_IN_BOUNDS_2D = EIDOS_OMP_MAX_THREADS;
int gEidos_OMP_threads_POINT_IN_BOUNDS_3D = EIDOS_OMP_MAX_THREADS;
Expand Down Expand Up @@ -451,6 +455,10 @@ void _Eidos_SetOpenMPThreadCounts(EidosPerTaskThreadCounts per_task_thread_count
gEidos_OMP_threads_RUNIF_2 = EIDOS_OMP_MAX_THREADS;
gEidos_OMP_threads_RUNIF_3 = EIDOS_OMP_MAX_THREADS;

gEidos_OMP_threads_SORT_INT = EIDOS_OMP_MAX_THREADS;
gEidos_OMP_threads_SORT_FLOAT = EIDOS_OMP_MAX_THREADS;
gEidos_OMP_threads_SORT_STRING = EIDOS_OMP_MAX_THREADS;

gEidos_OMP_threads_POINT_IN_BOUNDS_1D = EIDOS_OMP_MAX_THREADS;
gEidos_OMP_threads_POINT_IN_BOUNDS_2D = EIDOS_OMP_MAX_THREADS;
gEidos_OMP_threads_POINT_IN_BOUNDS_3D = EIDOS_OMP_MAX_THREADS;
Expand Down Expand Up @@ -581,6 +589,10 @@ void _Eidos_SetOpenMPThreadCounts(EidosPerTaskThreadCounts per_task_thread_count
gEidos_OMP_threads_RUNIF_2 = 16;
gEidos_OMP_threads_RUNIF_3 = 16;

gEidos_OMP_threads_SORT_INT = 16; // subject to revision
gEidos_OMP_threads_SORT_FLOAT = 16; // subject to revision
gEidos_OMP_threads_SORT_STRING = 16; // subject to revision

gEidos_OMP_threads_POINT_IN_BOUNDS_1D = 12;
gEidos_OMP_threads_POINT_IN_BOUNDS_2D = 12;
gEidos_OMP_threads_POINT_IN_BOUNDS_3D = 16;
Expand Down Expand Up @@ -713,6 +725,10 @@ void _Eidos_SetOpenMPThreadCounts(EidosPerTaskThreadCounts per_task_thread_count
gEidos_OMP_threads_RUNIF_2 = 40;
gEidos_OMP_threads_RUNIF_3 = 40;

gEidos_OMP_threads_SORT_INT = 40; // subject to revision
gEidos_OMP_threads_SORT_FLOAT = 40; // subject to revision
gEidos_OMP_threads_SORT_STRING = 40; // subject to revision

gEidos_OMP_threads_POINT_IN_BOUNDS_1D = 40;
gEidos_OMP_threads_POINT_IN_BOUNDS_2D = 40;
gEidos_OMP_threads_POINT_IN_BOUNDS_3D = 40;
Expand Down Expand Up @@ -870,6 +886,10 @@ void _Eidos_ClipOpenMPThreadCounts(void)
gEidos_OMP_threads_RUNIF_2 = std::min(gEidosMaxThreads, gEidos_OMP_threads_RUNIF_2);
gEidos_OMP_threads_RUNIF_3 = std::min(gEidosMaxThreads, gEidos_OMP_threads_RUNIF_3);

gEidos_OMP_threads_SORT_INT = std::min(gEidosMaxThreads, gEidos_OMP_threads_SORT_INT);
gEidos_OMP_threads_SORT_FLOAT = std::min(gEidosMaxThreads, gEidos_OMP_threads_SORT_FLOAT);
gEidos_OMP_threads_SORT_STRING = std::min(gEidosMaxThreads, gEidos_OMP_threads_SORT_STRING);

gEidos_OMP_threads_POINT_IN_BOUNDS_1D = std::min(gEidosMaxThreads, gEidos_OMP_threads_POINT_IN_BOUNDS_1D);
gEidos_OMP_threads_POINT_IN_BOUNDS_2D = std::min(gEidosMaxThreads, gEidos_OMP_threads_POINT_IN_BOUNDS_2D);
gEidos_OMP_threads_POINT_IN_BOUNDS_3D = std::min(gEidosMaxThreads, gEidos_OMP_threads_POINT_IN_BOUNDS_3D);
Expand Down
15 changes: 15 additions & 0 deletions eidos/eidos_openmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ class EidosDebugLock
#define EIDOS_OMPMIN_RUNIF_2 10000
#define EIDOS_OMPMIN_RUNIF_3 10000

// Sorting & ordering
#define EIDOS_OMPMIN_SORT_INT 4000
#define EIDOS_OMPMIN_SORT_FLOAT 4000
#define EIDOS_OMPMIN_SORT_STRING 4000

// Spatial point/map manipulation
#define EIDOS_OMPMIN_POINT_IN_BOUNDS_1D 2000
#define EIDOS_OMPMIN_POINT_IN_BOUNDS_2D 2000
Expand Down Expand Up @@ -452,6 +457,11 @@ class EidosDebugLock
#define EIDOS_OMPMIN_RUNIF_2 0
#define EIDOS_OMPMIN_RUNIF_3 0

// Sorting & ordering
#define EIDOS_OMPMIN_SORT_INT 0
#define EIDOS_OMPMIN_SORT_FLOAT 0
#define EIDOS_OMPMIN_SORT_STRING 0

// Spatial point/map manipulation
#define EIDOS_OMPMIN_POINT_IN_BOUNDS_1D 0
#define EIDOS_OMPMIN_POINT_IN_BOUNDS_2D 0
Expand Down Expand Up @@ -583,6 +593,11 @@ extern int gEidos_OMP_threads_RUNIF_1;
extern int gEidos_OMP_threads_RUNIF_2;
extern int gEidos_OMP_threads_RUNIF_3;

// Sorting & ordering
extern int gEidos_OMP_threads_SORT_INT;
extern int gEidos_OMP_threads_SORT_FLOAT;
extern int gEidos_OMP_threads_SORT_STRING;

// Spatial point/map manipulation; benchmark section P
extern int gEidos_OMP_threads_POINT_IN_BOUNDS_1D;
extern int gEidos_OMP_threads_POINT_IN_BOUNDS_2D;
Expand Down
Loading

0 comments on commit bb72a18

Please sign in to comment.