Skip to content

Commit 2879652

Browse files
committed
making nosv also with lpf and mpi (even if they don't work now)
1 parent 5d2537d commit 2879652

3 files changed

Lines changed: 140 additions & 71 deletions

File tree

examples/jacobi3d/meson.build

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,49 @@
11
testSuite = [ 'examples', 'jacobi3d' ]
22

3-
# Handling distributed engine options
43
if distributedEngine == 'mpi'
54
TaskRDistributedCppFlag = '-D_TASKR_DISTRIBUTED_ENGINE_MPI'
5+
66
mpirunExecutable = HiCRProject.get_variable('mpirunExecutable')
7-
elif distributedEngine == 'lpf'
8-
TaskRDistributedCppFlag = '-D_TASKR_DISTRIBUTED_ENGINE_LPF'
9-
lpfrunExecutable = HiCRProject.get_variable('lpfrunExecutable')
10-
elif distributedEngine == 'none'
11-
TaskRDistributedCppFlag = '-D_TASKR_DISTRIBUTED_ENGINE_NONE'
12-
endif
137

14-
if distributedEngine == 'mpi'
158
if 'boost' in get_option('executionStateType') and 'pthreads' in get_option('processingUnitType')
169
threading = executable('threading', [ 'source/pthreads.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )
10+
1711
if get_option('buildTests')
1812
test('threading', mpirunExecutable, args : [ '-n', '2', '--oversubscribe', threading.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], suite: testSuite, workdir: threading.path() + '.p' )
1913
endif
2014
endif
2115

22-
# nOS-V backend with MPI not yet supported (we run without mpirun)
2316
if 'nosv' in get_option('executionStateType') and 'nosv' in get_option('processingUnitType')
2417
nosv = executable('nosv', [ 'source/nosv.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )
25-
18+
2619
if get_option('buildTests')
27-
test('nosv', nosv, args : [ '-n', '64', '-i', '10' ], is_parallel : false, suite: testSuite, workdir: nosv.path() + '.p' )
20+
test('nosv', mpirunExecutable, args : [ '-n', '2', '--oversubscribe', nosv.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], is_parallel : false, suite: testSuite, workdir: nosv.path() + '.p' )
2821
endif
2922
endif
3023

3124
elif distributedEngine == 'lpf'
25+
TaskRDistributedCppFlag = '-D_TASKR_DISTRIBUTED_ENGINE_LPF'
26+
27+
lpfrunExecutable = HiCRProject.get_variable('lpfrunExecutable')
28+
3229
if 'boost' in get_option('executionStateType') and 'pthreads' in get_option('processingUnitType')
3330
threading = executable('threading', [ 'source/pthreads.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )
31+
3432
if get_option('buildTests')
35-
test('threading', lpfrunExecutable, args : [ '-n', '2', threading.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], suite: testSuite, workdir: threading.path() + '.p' )
33+
test('threading', lpfrunExecutable, args : [ '-n', '2', '-engine', 'zero', threading.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], suite: testSuite, workdir: threading.path() + '.p' )
3634
endif
3735
endif
3836

39-
# nOS-V backend with LPF not yet supported (we run without lpfrun)
40-
# if 'nosv' in get_option('executionStateType') and 'nosv' in get_option('processingUnitType')
41-
# nosv = executable('nosv', [ 'source/nosv.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )
37+
if 'nosv' in get_option('executionStateType') and 'nosv' in get_option('processingUnitType')
38+
nosv = executable('nosv', [ 'source/nosv.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )
39+
40+
if get_option('buildTests')
41+
test('nosv', lpfrunExecutable, args : [ '-n', '2', '-engine', 'zero', nosv.full_path(), '-px', '1', '-py', '1', '-pz', '2', '-lx', '1', '-ly', '2', '-lz', '2', '-n', '64', '-i', '10'], is_parallel : false, suite: testSuite, workdir: nosv.path() + '.p' )
42+
endif
43+
endif
44+
elif distributedEngine == 'none' # Atm these are segfaulting (TODO fix!)
45+
TaskRDistributedCppFlag = '-D_TASKR_DISTRIBUTED_ENGINE_NONE'
4246

43-
# if get_option('buildTests')
44-
# test('nosv', nosv, args : [ '-n', '64', '-i', '10' ], is_parallel : false, suite: testSuite, workdir: nosv.path() + '.p' )
45-
# endif
46-
# endif
47-
elif distributedEngine == 'none' # Atm these segfault
4847
if 'boost' in get_option('executionStateType') and 'pthreads' in get_option('processingUnitType')
4948
threading = executable('threading', [ 'source/pthreads.cpp', 'source/grid.cpp' ], dependencies: [ TaskRBuildDep ], cpp_args: [ TaskRDistributedCppFlag ] )
5049

examples/jacobi3d/source/nosv.cpp

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@
2626
#include <hicr/backends/nosv/common.hpp>
2727
#include <hicr/backends/nosv/computeManager.hpp>
2828

29+
#ifdef _TASKR_DISTRIBUTED_ENGINE_LPF
30+
#include <lpf/core.h>
31+
#include <lpf/mpi.h>
32+
#include <mpi.h>
33+
#include <hicr/backends/lpf/communicationManager.hpp>
34+
#include <hicr/backends/mpi/instanceManager.hpp>
35+
#include <hicr/backends/lpf/memoryManager.hpp>
36+
#endif
37+
2938
#ifdef _TASKR_DISTRIBUTED_ENGINE_MPI
3039
#include <hicr/backends/mpi/communicationManager.hpp>
3140
#include <hicr/backends/mpi/instanceManager.hpp>
@@ -42,6 +51,7 @@
4251
#include "task.hpp"
4352
#include "jacobi3d.hpp"
4453

54+
4555
// Setting default values (globali)
4656
size_t gDepth = 1;
4757
size_t N = 128;
@@ -115,6 +125,55 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
115125
instanceManager->finalize();
116126
}
117127

128+
129+
#ifdef _TASKR_DISTRIBUTED_ENGINE_LPF
130+
131+
// flag needed when using MPI to launch
132+
const int LPF_MPI_AUTO_INITIALIZE = 0;
133+
134+
/**
135+
* #DEFAULT_MEMSLOTS The memory slots used by LPF
136+
* in lpf_resize_memory_register . This value is currently
137+
* guessed as sufficiently large for a program
138+
*/
139+
#define DEFAULT_MEMSLOTS 100
140+
141+
/**
142+
* #DEFAULT_MSGSLOTS The message slots used by LPF
143+
* in lpf_resize_message_queue . This value is currently
144+
* guessed as sufficiently large for a program
145+
*/
146+
#define DEFAULT_MSGSLOTS 100
147+
148+
// Global pointer to the
149+
HiCR::InstanceManager *instanceManager;
150+
151+
void spmd(lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args)
152+
{
153+
// Initializing LPF
154+
CHECK(lpf_resize_message_queue(lpf, DEFAULT_MSGSLOTS));
155+
CHECK(lpf_resize_memory_register(lpf, DEFAULT_MEMSLOTS));
156+
CHECK(lpf_sync(lpf, LPF_SYNC_DEFAULT));
157+
158+
// Creating HWloc topology object
159+
hwloc_topology_t topology;
160+
161+
// Reserving memory for hwloc
162+
hwloc_topology_init(&topology);
163+
164+
// Initializing host (CPU) topology manager
165+
HiCR::backend::hwloc::TopologyManager tm(&topology);
166+
167+
// Creating memory and communication managers
168+
std::unique_ptr<HiCR::CommunicationManager> communicationManager = std::make_unique<HiCR::backend::lpf::CommunicationManager>(nprocs, pid, lpf);
169+
std::unique_ptr<HiCR::MemoryManager> memoryManager = std::make_unique<HiCR::backend::lpf::MemoryManager>(lpf);
170+
171+
// Running the remote memcpy example
172+
jacobiDriver(instanceManager, communicationManager.get(), memoryManager.get());
173+
}
174+
#endif
175+
176+
118177
int main(int argc, char *argv[])
119178
{
120179
// Initialize nosv
@@ -142,7 +201,16 @@ int main(int argc, char *argv[])
142201
}
143202

144203
#ifdef _TASKR_DISTRIBUTED_ENGINE_LPF
145-
#error "LPF backend not supported yet for nOS-V backend"
204+
// Initializing instance manager
205+
auto im = HiCR::backend::mpi::InstanceManager::createDefault(&argc, &argv);
206+
instanceManager = im.get();
207+
208+
lpf_init_t init;
209+
lpf_args_t args;
210+
211+
CHECK(lpf_mpi_initialize_with_mpicomm(MPI_COMM_WORLD, &init));
212+
CHECK(lpf_hook(init, &spmd, args));
213+
CHECK(lpf_mpi_finalize(init));
146214
#endif
147215

148216
#ifdef _TASKR_DISTRIBUTED_ENGINE_MPI

examples/jacobi3d/source/pthreads.cpp

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <lpf/mpi.h>
3030
#include <mpi.h>
3131
#include <hicr/backends/lpf/communicationManager.hpp>
32-
#include <hicr/backends/hwloc/instanceManager.hpp>
32+
#include <hicr/backends/mpi/instanceManager.hpp>
3333
#include <hicr/backends/lpf/memoryManager.hpp>
3434
#endif
3535

@@ -49,53 +49,6 @@
4949
#include "task.hpp"
5050
#include "jacobi3d.hpp"
5151

52-
#ifdef _TASKR_DISTRIBUTED_ENGINE_LPF
53-
54-
// flag needed when using MPI to launch
55-
const int LPF_MPI_AUTO_INITIALIZE = 0;
56-
57-
/**
58-
* #DEFAULT_MEMSLOTS The memory slots used by LPF
59-
* in lpf_resize_memory_register . This value is currently
60-
* guessed as sufficiently large for a program
61-
*/
62-
#define DEFAULT_MEMSLOTS 100
63-
64-
/**
65-
* #DEFAULT_MSGSLOTS The message slots used by LPF
66-
* in lpf_resize_message_queue . This value is currently
67-
* guessed as sufficiently large for a program
68-
*/
69-
#define DEFAULT_MSGSLOTS 100
70-
71-
// Global pointer to the
72-
HiCR::InstanceManager *instanceManager;
73-
74-
void spmd(lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args)
75-
{
76-
// Initializing LPF
77-
CHECK(lpf_resize_message_queue(lpf, DEFAULT_MSGSLOTS));
78-
CHECK(lpf_resize_memory_register(lpf, DEFAULT_MEMSLOTS));
79-
CHECK(lpf_sync(lpf, LPF_SYNC_DEFAULT));
80-
81-
// Creating HWloc topology object
82-
hwloc_topology_t topology;
83-
84-
// Reserving memory for hwloc
85-
hwloc_topology_init(&topology);
86-
87-
// Initializing host (CPU) topology manager
88-
HiCR::backend::hwloc::TopologyManager tm(&topology);
89-
90-
// Creating memory and communication managers
91-
HiCR::backend::lpf::MemoryManager mm(lpf);
92-
HiCR::backend::lpf::CommunicationManager cc(nprocs, pid, lpf);
93-
94-
// Running the remote memcpy example
95-
jaccobiDriver(instanceManager, &mm, &cc);
96-
}
97-
#endif
98-
9952
// Setting default values (globali)
10053
size_t gDepth = 1;
10154
size_t N = 128;
@@ -168,10 +121,56 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
168121
// running the Jacobi3D example
169122
jacobi3d(instanceManager, taskr, g.get(), gDepth, N, nIters, pt, lt);
170123

171-
// Finalizing instances
172-
instanceManager->finalize();
124+
173125
}
174126

127+
#ifdef _TASKR_DISTRIBUTED_ENGINE_LPF
128+
129+
// flag needed when using MPI to launch
130+
const int LPF_MPI_AUTO_INITIALIZE = 0;
131+
132+
/**
133+
* #DEFAULT_MEMSLOTS The memory slots used by LPF
134+
* in lpf_resize_memory_register . This value is currently
135+
* guessed as sufficiently large for a program
136+
*/
137+
#define DEFAULT_MEMSLOTS 100
138+
139+
/**
140+
* #DEFAULT_MSGSLOTS The message slots used by LPF
141+
* in lpf_resize_message_queue . This value is currently
142+
* guessed as sufficiently large for a program
143+
*/
144+
#define DEFAULT_MSGSLOTS 100
145+
146+
// Global pointer to the
147+
HiCR::InstanceManager *instanceManager;
148+
149+
void spmd(lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args)
150+
{
151+
// Initializing LPF
152+
CHECK(lpf_resize_message_queue(lpf, DEFAULT_MSGSLOTS));
153+
CHECK(lpf_resize_memory_register(lpf, DEFAULT_MEMSLOTS));
154+
CHECK(lpf_sync(lpf, LPF_SYNC_DEFAULT));
155+
156+
// Creating HWloc topology object
157+
hwloc_topology_t topology;
158+
159+
// Reserving memory for hwloc
160+
hwloc_topology_init(&topology);
161+
162+
// Initializing host (CPU) topology manager
163+
HiCR::backend::hwloc::TopologyManager tm(&topology);
164+
165+
// Creating memory and communication managers
166+
std::unique_ptr<HiCR::CommunicationManager> communicationManager = std::make_unique<HiCR::backend::lpf::CommunicationManager>(nprocs, pid, lpf);
167+
std::unique_ptr<HiCR::MemoryManager> memoryManager = std::make_unique<HiCR::backend::lpf::MemoryManager>(lpf);
168+
169+
// Running the remote memcpy example
170+
jacobiDriver(instanceManager, communicationManager.get(), memoryManager.get());
171+
}
172+
#endif
173+
175174
int main(int argc, char *argv[])
176175
{
177176
//// Instantiating distributed execution machinery
@@ -219,4 +218,7 @@ int main(int argc, char *argv[])
219218
// Running the remote memcpy example
220219
jacobiDriver(instanceManager.get(), communicationManager.get(), &memoryManager.get());
221220
#endif
221+
222+
// Finalizing instances
223+
instanceManager->finalize();
222224
}

0 commit comments

Comments
 (0)