Skip to content

Commit bd75493

Browse files
committed
code formatting
1 parent f69c6ca commit bd75493

5 files changed

Lines changed: 47 additions & 48 deletions

File tree

examples/conditionVariable/cpp/conditionVariableWaitForCondition.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ void conditionVariableWaitForCondition(taskr::Runtime &taskr)
5757
{
5858
printf("Thread 1: I wait (forever) for the value to turn 2\n");
5959
mutex.lock(task);
60-
bool wasNotified = cv.waitFor(task, mutex, [&]() { return value == 2; }, forever);
60+
bool wasNotified = cv.waitFor(
61+
task, mutex, [&]() { return value == 2; }, forever);
6162
mutex.unlock(task);
6263
if (wasNotified == false)
6364
{
@@ -72,7 +73,8 @@ void conditionVariableWaitForCondition(taskr::Runtime &taskr)
7273
printf("Thread 1: I wait (with timeout) for the value to turn 3 (won't happen)\n");
7374
mutex.lock(task);
7475
auto startTime = std::chrono::high_resolution_clock::now();
75-
bool wasNotified = cv.waitFor(task, mutex, [&]() { return value == 3; }, timeoutTimeUs);
76+
bool wasNotified = cv.waitFor(
77+
task, mutex, [&]() { return value == 3; }, timeoutTimeUs);
7678
auto currentTime = std::chrono::high_resolution_clock::now();
7779
auto elapsedTime = (size_t)std::chrono::duration_cast<std::chrono::microseconds>(currentTime - startTime).count();
7880
mutex.unlock(task);
@@ -99,7 +101,8 @@ void conditionVariableWaitForCondition(taskr::Runtime &taskr)
99101
// Waiting for the other thread to set the first value
100102
printf("Thread 2: First, I'll wait for the value to become 1\n");
101103
mutex.lock(task);
102-
bool wasNotified = cv.waitFor(task, mutex, [&]() { return value == 1; }, forever);
104+
bool wasNotified = cv.waitFor(
105+
task, mutex, [&]() { return value == 1; }, forever);
103106
mutex.unlock(task);
104107
if (wasNotified == false)
105108
{

examples/jacobi3d/source/jacobi3d.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ void jacobi3d(HiCR::InstanceManager *instanceManager,
183183

184184
for (size_t i = 0; i < instanceCount - 1; i++)
185185
{
186-
while (g->residualConsumerChannel->isEmpty());
186+
while (g->residualConsumerChannel->isEmpty())
187+
;
187188
double *residualPtr = (double *)g->residualConsumerChannel->getTokenBuffer()->getSourceLocalMemorySlot()->getPointer() + g->residualConsumerChannel->peek(0);
188189
g->residualConsumerChannel->pop();
189190
globalRes += *residualPtr;

examples/jacobi3d/source/nosv.cpp

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#include "task.hpp"
5252
#include "jacobi3d.hpp"
5353

54-
5554
// Setting default values (globali)
5655
size_t gDepth = 1;
5756
size_t N = 128;
@@ -69,7 +68,7 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
6968

7069
// Attaching the main thread
7170
check(nosv_attach(&mainTask, NULL, NULL, NOSV_ATTACH_NONE));
72-
71+
7372
// Creating (local host) topology manager
7473
const auto topologyManager = HiCR::backend::hwloc::TopologyManager::createDefault();
7574

@@ -101,36 +100,35 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
101100
// Assuming one process per numa domain
102101
// Looking for Domains that are not zero (Slurm non --exclusive issue)
103102
size_t numaDomainId;
104-
for(size_t i = 0; i < numaDomains.size(); ++i)
103+
for (size_t i = 0; i < numaDomains.size(); ++i)
105104
{
106105
numaDomainId = (myInstanceId + i) % numaDomains.size();
107-
if(numaDomains[numaDomainId]->getComputeResourceList().size() > 0)
108-
{
109-
break;
110-
}
106+
if (numaDomains[numaDomainId]->getComputeResourceList().size() > 0) { break; }
111107
}
112108

113-
auto numaDomain = numaDomains[numaDomainId];
109+
auto numaDomain = numaDomains[numaDomainId];
114110
printf("Instance %lu - Using NUMA domain: %lu\n", myInstanceId, numaDomainId);
115111

116112
// Updating the compute resource list
117113
auto computeResources = numaDomain->getComputeResourceList();
118114

119115
// Compute resources to use
120116
HiCR::Device::computeResourceList_t cr;
121-
int size;
122-
MPI_Comm_size( MPI_COMM_WORLD, &size);
117+
int size;
118+
MPI_Comm_size(MPI_COMM_WORLD, &size);
123119

124120
// for(size_t i = 0; i < (size_t)(lt.x * lt.y * lt.z); i++)
125121
// {
126122
// cr.push_back(computeResources[(2+i)%(computeResources.size())]); //21,43,65,87 are broken for nOS-V
127123
// }
128124

129125
// cr.push_back(numaDomains[0]->getComputeResourceList()[0]);
130-
131-
for (int i = 0; i < size; ++i) {
132-
if (myInstanceId == (size_t)i) {
133-
auto itr = computeResources.begin();
126+
127+
for (int i = 0; i < size; ++i)
128+
{
129+
if (myInstanceId == (size_t)i)
130+
{
131+
auto itr = computeResources.begin();
134132
for (size_t i = 0; i < computeResources.size(); i++)
135133
{
136134
// Getting up-casted pointer for the processing unit
@@ -142,15 +140,17 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
142140
// Getting the logical processor ID of the compute resource
143141
auto pid = c->getProcessorId();
144142

145-
if(pid != 21 && pid != 43 && pid != 65 && pid != 87)
143+
if (pid != 21 && pid != 43 && pid != 65 && pid != 87)
146144
{
147-
printf("%u ", pid); fflush(stdout);
148-
145+
printf("%u ", pid);
146+
fflush(stdout);
147+
149148
cr.push_back(*itr);
150149
}
151150
itr++;
152151
}
153-
printf("]\n"); fflush(stdout);
152+
printf("]\n");
153+
fflush(stdout);
154154
}
155155
MPI_Barrier(MPI_COMM_WORLD);
156156
}
@@ -189,7 +189,6 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
189189
// check(nosv_shutdown());
190190
}
191191

192-
193192
#ifdef _TASKR_DISTRIBUTED_ENGINE_LPF
194193

195194
// flag needed when using MPI to launch
@@ -230,21 +229,17 @@ void spmd(lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args)
230229

231230
// Creating memory and communication managers
232231
std::unique_ptr<HiCR::CommunicationManager> communicationManager = std::make_unique<HiCR::backend::lpf::CommunicationManager>(nprocs, pid, lpf);
233-
std::unique_ptr<HiCR::MemoryManager> memoryManager = std::make_unique<HiCR::backend::lpf::MemoryManager>(lpf);
232+
std::unique_ptr<HiCR::MemoryManager> memoryManager = std::make_unique<HiCR::backend::lpf::MemoryManager>(lpf);
234233

235234
// Running the remote memcpy example
236235
jacobiDriver(instanceManager, communicationManager.get(), memoryManager.get());
237236
}
238237
#endif
239238

240-
241239
int main(int argc, char *argv[])
242240
{
243-
244-
245241
//// Instantiating distributed execution machinery
246242

247-
248243
#ifdef _TASKR_DISTRIBUTED_ENGINE_LPF
249244
// Initializing instance manager
250245
auto im = HiCR::backend::mpi::InstanceManager::createDefault(&argc, &argv);
@@ -263,7 +258,6 @@ int main(int argc, char *argv[])
263258
if (!strcmp(argv[i], "-i")) nIters = atoi(argv[++i]);
264259
}
265260

266-
267261
lpf_init_t init;
268262
lpf_args_t args;
269263

examples/jacobi3d/source/pthreads.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ D3 lt = D3({.x = 1, .y = 1, .z = 1});
5959
void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationManager *communicationManager, HiCR::MemoryManager *memoryManager)
6060
{
6161
int rank, size;
62-
MPI_Comm_rank( MPI_COMM_WORLD, &rank);
63-
MPI_Comm_size( MPI_COMM_WORLD, &size);
62+
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
63+
MPI_Comm_size(MPI_COMM_WORLD, &size);
6464

6565
// Creating (local host) topology manager
6666
const auto topologyManager = HiCR::backend::hwloc::TopologyManager::createDefault();
@@ -93,16 +93,13 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
9393
// Assuming one process per numa domain
9494
// Looking for Domains that are not zero (Slurm non --exclusive issue)
9595
size_t numaDomainId;
96-
for(size_t i = 0; i < numaDomains.size(); ++i)
96+
for (size_t i = 0; i < numaDomains.size(); ++i)
9797
{
9898
numaDomainId = (myInstanceId + i) % numaDomains.size();
99-
if(numaDomains[numaDomainId]->getComputeResourceList().size() > 0)
100-
{
101-
break;
102-
}
99+
if (numaDomains[numaDomainId]->getComputeResourceList().size() > 0) { break; }
103100
}
104101

105-
auto numaDomain = numaDomains[numaDomainId];
102+
auto numaDomain = numaDomains[numaDomainId];
106103
printf("Instance %lu - Using NUMA domain: %lu\n", myInstanceId, numaDomainId);
107104

108105
// Updating the compute resource list
@@ -114,14 +111,16 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
114111

115112
// for(size_t i = 0; i < (size_t)(lt.x * lt.y * lt.z); i++)
116113
// {
117-
// cr.push_back(computeResources[(i+2)%(computeResources.size())]);
114+
// cr.push_back(computeResources[(i+2)%(computeResources.size())]);
118115
// }
119116

120117
// cr.push_back(numaDomains[0]->getComputeResourceList()[0]);
121-
122-
for (int i = 0; i < size; ++i) {
123-
if (myInstanceId == (size_t)i) {
124-
auto itr = computeResources.begin();
118+
119+
for (int i = 0; i < size; ++i)
120+
{
121+
if (myInstanceId == (size_t)i)
122+
{
123+
auto itr = computeResources.begin();
125124
for (size_t i = 0; i < computeResources.size(); i++)
126125
{
127126
// Getting up-casted pointer for the processing unit
@@ -133,16 +132,18 @@ void jacobiDriver(HiCR::InstanceManager *instanceManager, HiCR::CommunicationMan
133132
// Getting the logical processor ID of the compute resource
134133
auto pid = c->getProcessorId();
135134

136-
if(pid != 21 && pid != 43 && pid != 65 && pid != 87) //21,43,65,87 are broken for nOS-V
135+
if (pid != 21 && pid != 43 && pid != 65 && pid != 87) //21,43,65,87 are broken for nOS-V
137136
{
138-
printf("%u ", pid); fflush(stdout);
139-
137+
printf("%u ", pid);
138+
fflush(stdout);
139+
140140
cr.push_back(*itr);
141141
}
142142

143143
itr++;
144144
}
145-
printf("]\n"); fflush(stdout);
145+
printf("]\n");
146+
fflush(stdout);
146147
}
147148
MPI_Barrier(MPI_COMM_WORLD);
148149
}
@@ -215,7 +216,7 @@ void spmd(lpf_t lpf, lpf_pid_t pid, lpf_pid_t nprocs, lpf_args_t args)
215216

216217
// Creating memory and communication managers
217218
std::unique_ptr<HiCR::CommunicationManager> communicationManager = std::make_unique<HiCR::backend::lpf::CommunicationManager>(nprocs, pid, lpf);
218-
std::unique_ptr<HiCR::MemoryManager> memoryManager = std::make_unique<HiCR::backend::lpf::MemoryManager>(lpf);
219+
std::unique_ptr<HiCR::MemoryManager> memoryManager = std::make_unique<HiCR::backend::lpf::MemoryManager>(lpf);
219220

220221
// Running the remote memcpy example
221222
jacobiDriver(instanceManager, communicationManager.get(), memoryManager.get());

include/taskr/runtime.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ class Runtime
320320
// // Getting the logical processor ID of the compute resource
321321
// auto pid = c->getProcessorId();
322322
// printf("activating PU with PID: %d\n", pid);
323-
323+
324324
// Creating new task worker
325325
auto taskWorker = std::make_shared<taskr::Worker>(
326326
taskWorkerId, _executionStateComputeManager, _processingUnitComputeManager, [this, taskWorkerId]() -> taskr::Task * { return taskWorkerLoop(taskWorkerId); });

0 commit comments

Comments
 (0)