From 196fcac032480e7f31aff2c2e120a45a0f0a48c6 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 27 Apr 2018 18:43:09 -0700 Subject: [PATCH 01/30] hopefully locking to core. --- .idea/codeStyles/Project.xml | 29 +++++++++++++++++++++++++++++ .idea/vcs.xml | 6 ++++++ Core/BGDriver.cpp | 13 ++++++++++++- Core/Cluster.cpp | 11 +++++++++-- Core/Cluster.h | 2 ++ Core/ClusterInfo.h | 3 +++ 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 00000000..30aa626c --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Core/BGDriver.cpp b/Core/BGDriver.cpp index 83be51d3..724490fd 100644 --- a/Core/BGDriver.cpp +++ b/Core/BGDriver.cpp @@ -216,10 +216,21 @@ bool createAllModelClassInstances(TiXmlDocument* simDoc, SimulationInfo *simInfo // create clusters int numClusterNeurons = simInfo->totalNeurons / g_numClusters; // number of neurons in cluster - for (int iCluster = 0; iCluster < g_numClusters; iCluster++) { + //https://stackoverflow.com/questions/150355/programmatically-find-the-number-of-cores-on-a-machine + unsigned int nCores = std::thread::hardware_concurrency(); + int jumpPerThread = nCores / g_numClusters; + int coreAssigner = 0; + + + for (int iCluster = 0; iCluster < g_numClusters; iCluster++) { // This is looping from 0 to num of threads. // create a cluster information ClusterInfo *clusterInfo = new ClusterInfo(); clusterInfo->clusterID = iCluster; + if(iCluster > nCores) { + coreAssigner = 0; + } + clusterInfo->assignedCore = (jumpPerThread * coreAssigner); + coreAssigner++; clusterInfo->clusterNeuronsBegin = numClusterNeurons * iCluster; if (iCluster == g_numClusters - 1) { clusterInfo->totalClusterNeurons = simInfo->totalNeurons - numClusterNeurons * (g_numClusters - 1); diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 6fdf59cc..d6ca42a2 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -130,7 +130,14 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c } // Create an advanceThread - std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); + int lockedCore = clr_info->assignedCore; + + cpu_set_t my_set; + CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp + CPU_SET(lockedCore, &my_set); + std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! + int myPid = thAdvance.getid(); + sched_setaffinity(myPid, sizeof(cpu_set_t), &my_set); // Leave it running thAdvance.detach(); @@ -154,7 +161,7 @@ void Cluster::advanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_inf break; } - // Advance neurons and synapses indepedently (without barrier synchronization) + // Advance neurons and synapses independently (without barrier synchronization) // within synaptic transmission delay period. for (int iStepOffset = 0; iStepOffset < m_nSynapticTransDelay; iStepOffset++) { if (sim_info->pInput != NULL) { diff --git a/Core/Cluster.h b/Core/Cluster.h index 68113647..dbedce70 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -53,11 +53,13 @@ #include "Layout.h" #include #include "Barrier.hpp" +#include class Cluster { public: Cluster(IAllNeurons *neurons, IAllSynapses *synapses); + int assignedCore; virtual ~Cluster(); /** diff --git a/Core/ClusterInfo.h b/Core/ClusterInfo.h index 632810f3..5a99c1b6 100644 --- a/Core/ClusterInfo.h +++ b/Core/ClusterInfo.h @@ -75,6 +75,9 @@ class ClusterInfo //! Count of neurons in the cluster int totalClusterNeurons; + //! Core to which this cluster is locked + int assignedCore; + //! List of summation points (either host or device memory) BGFLOAT* pClusterSummationMap; From 1bdf19d9884ca7927f7528987f9c669756482d50 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 29 Apr 2018 20:05:08 -0700 Subject: [PATCH 02/30] adding a cout for debugging. --- Core/BGDriver.cpp | 1 + Core/Cluster.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Core/BGDriver.cpp b/Core/BGDriver.cpp index 724490fd..27a44f22 100644 --- a/Core/BGDriver.cpp +++ b/Core/BGDriver.cpp @@ -231,6 +231,7 @@ bool createAllModelClassInstances(TiXmlDocument* simDoc, SimulationInfo *simInfo } clusterInfo->assignedCore = (jumpPerThread * coreAssigner); coreAssigner++; + clusterInfo->clusterNeuronsBegin = numClusterNeurons * iCluster; if (iCluster == g_numClusters - 1) { clusterInfo->totalClusterNeurons = simInfo->totalNeurons - numClusterNeurons * (g_numClusters - 1); diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index d6ca42a2..4f5ce4e6 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -138,6 +138,7 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! int myPid = thAdvance.getid(); sched_setaffinity(myPid, sizeof(cpu_set_t), &my_set); + cout << "thread " << myPid << " locked to core: " << assignedCore << endl; // Leave it running thAdvance.detach(); From 813f9dce53365b807f80166b63f84e3e018a2b8a Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 29 Apr 2018 20:31:11 -0700 Subject: [PATCH 03/30] fixing --- Core/Cluster.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 4f5ce4e6..802d62c0 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -132,13 +132,13 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c // Create an advanceThread int lockedCore = clr_info->assignedCore; - cpu_set_t my_set; + cpu_set_t my_set; //http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! int myPid = thAdvance.getid(); - sched_setaffinity(myPid, sizeof(cpu_set_t), &my_set); - cout << "thread " << myPid << " locked to core: " << assignedCore << endl; + pthread_setaffinity_np(thAdvance, sizeof(cpu_set_t), &my_set); + cout << "thread " << " locked to core: " << assignedCore << endl; // Leave it running thAdvance.detach(); From b9b2c36c817bff63905be07791d3af56bd61221f Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 29 Apr 2018 20:41:17 -0700 Subject: [PATCH 04/30] Add files via upload updated configfiles from master. --- configfiles/1_tR_1.0--fE_0.90_10000.xml | 84 ++++++++++++++++++++++ configfiles/full_tR_1.0--fE_0.90_10000.xml | 84 ++++++++++++++++++++++ configfiles/full_tR_1.0--fE_0.98_10000.xml | 84 ++++++++++++++++++++++ configfiles/full_tR_1.9--fE_0.98_10000.xml | 84 ++++++++++++++++++++++ configfiles/static_izh_1000.xml | 2 +- configfiles/tR_0.1--fE_0.80_10000.xml | 6 +- configfiles/tR_0.1--fE_0.90.xml | 6 +- configfiles/tR_0.1--fE_0.90_10000.xml | 6 +- configfiles/test-large-conected.xml | 6 +- configfiles/test-large-long.xml | 6 +- configfiles/test-large-short.xml | 6 +- configfiles/test-medium-100.xml | 6 +- configfiles/test-medium-2.xml | 6 +- configfiles/test-medium-500.xml | 6 +- configfiles/test-medium.xml | 6 +- configfiles/test-small-connected.xml | 6 +- configfiles/test-small.xml | 6 +- configfiles/test-tiny.xml | 6 +- 18 files changed, 376 insertions(+), 40 deletions(-) create mode 100644 configfiles/1_tR_1.0--fE_0.90_10000.xml create mode 100644 configfiles/full_tR_1.0--fE_0.90_10000.xml create mode 100644 configfiles/full_tR_1.0--fE_0.98_10000.xml create mode 100644 configfiles/full_tR_1.9--fE_0.98_10000.xml diff --git a/configfiles/1_tR_1.0--fE_0.90_10000.xml b/configfiles/1_tR_1.0--fE_0.90_10000.xml new file mode 100644 index 00000000..36ba4e64 --- /dev/null +++ b/configfiles/1_tR_1.0--fE_0.90_10000.xml @@ -0,0 +1,84 @@ + + + + + 100 + 100 + 1 + + + 100.0 + 1 + + + 200 + 200 + + + 777 + + + /tmp/1_tR_1.0--fE_0.90_10000.h5 + + + + + + + 13.5e-09 + 13.5e-09 + + + 1.0e-09 + 1.5e-09 + + + 15.0e-03 + 15.0e-03 + + + 0.0 + 0.0 + + + 13.5e-03 + 13.5e-03 + + + 13.0e-03 + 13.0e-03 + + + 13.565e-3 + 13.655e-3 + + + 13.0e-3 + 13.0e-3 + + + + + + + + + + 0.60 + 0.10 + 0.0001 + 1.0 + 0.1 + 0.4 + + + + + + configfiles/NList/activeNList_0.10_10000.xml + configfiles/NList/inhNList_0.90_10000.xml + configfiles/NList/probedNList_10000.xml + + + + diff --git a/configfiles/full_tR_1.0--fE_0.90_10000.xml b/configfiles/full_tR_1.0--fE_0.90_10000.xml new file mode 100644 index 00000000..d19e52cc --- /dev/null +++ b/configfiles/full_tR_1.0--fE_0.90_10000.xml @@ -0,0 +1,84 @@ + + + + + 100 + 100 + 1 + + + 100.0 + 600 + + + 200 + 200 + + + 777 + + + /tmp/1107_full_tR_1.0--fE_0.90_cerberus.h5 + + + + + + + 13.5e-09 + 13.5e-09 + + + 1.0e-09 + 1.5e-09 + + + 15.0e-03 + 15.0e-03 + + + 0.0 + 0.0 + + + 13.5e-03 + 13.5e-03 + + + 13.0e-03 + 13.0e-03 + + + 13.565e-3 + 13.655e-3 + + + 13.0e-3 + 13.0e-3 + + + + + + + + + + 0.60 + 0.10 + 0.0001 + 1.0 + 0.1 + 0.4 + + + + + + configfiles/NList/activeNList_0.10_10000.xml + configfiles/NList/inhNList_0.90_10000.xml + configfiles/NList/probedNList_10000.xml + + + + diff --git a/configfiles/full_tR_1.0--fE_0.98_10000.xml b/configfiles/full_tR_1.0--fE_0.98_10000.xml new file mode 100644 index 00000000..3213919c --- /dev/null +++ b/configfiles/full_tR_1.0--fE_0.98_10000.xml @@ -0,0 +1,84 @@ + + + + + 100 + 100 + 1 + + + 100.0 + 600 + + + 200 + 200 + + + 777 + + + /tmp/0125_tR_1.0--fE_0.98_10000.h5 + + + + + + + 13.5e-09 + 13.5e-09 + + + 1.0e-09 + 1.5e-09 + + + 15.0e-03 + 15.0e-03 + + + 0.0 + 0.0 + + + 13.5e-03 + 13.5e-03 + + + 13.0e-03 + 13.0e-03 + + + 13.565e-3 + 13.655e-3 + + + 13.0e-3 + 13.0e-3 + + + + + + + + + + 0.60 + 0.10 + 0.0001 + 1.0 + 0.1 + 0.4 + + + + + + configfiles/NList/activeNList_0.10_10000.xml + configfiles/NList/inhNList_0.98_10000.xml + configfiles/NList/probedNList_10000.xml + + + + diff --git a/configfiles/full_tR_1.9--fE_0.98_10000.xml b/configfiles/full_tR_1.9--fE_0.98_10000.xml new file mode 100644 index 00000000..e69935eb --- /dev/null +++ b/configfiles/full_tR_1.9--fE_0.98_10000.xml @@ -0,0 +1,84 @@ + + + + + 100 + 100 + 1 + + + 100.0 + 600 + + + 200 + 200 + + + 777 + + + /tmp/0214_tR_1.9--fE_0.98_10000.h5 + + + + + + + 13.5e-09 + 13.5e-09 + + + 1.0e-09 + 1.5e-09 + + + 15.0e-03 + 15.0e-03 + + + 0.0 + 0.0 + + + 13.5e-03 + 13.5e-03 + + + 13.0e-03 + 13.0e-03 + + + 13.565e-3 + 13.655e-3 + + + 13.0e-3 + 13.0e-3 + + + + + + + + + + 0.60 + 0.10 + 0.0001 + 1.9 + 0.1 + 0.4 + + + + + + configfiles/NList/activeNList_0.10_10000.xml + configfiles/NList/inhNList_0.98_10000.xml + configfiles/NList/probedNList_10000.xml + + + + diff --git a/configfiles/static_izh_1000.xml b/configfiles/static_izh_1000.xml index c26b3d7c..abcaab2c 100644 --- a/configfiles/static_izh_1000.xml +++ b/configfiles/static_izh_1000.xml @@ -104,7 +104,7 @@ configfiles/NList/inhNList__1000.xml - configfiles/NList/probedNList_1000.xml + configfiles/NList/probedNList_1000.xml diff --git a/configfiles/tR_0.1--fE_0.80_10000.xml b/configfiles/tR_0.1--fE_0.80_10000.xml index 3dd33a6f..5c9464cd 100644 --- a/configfiles/tR_0.1--fE_0.80_10000.xml +++ b/configfiles/tR_0.1--fE_0.80_10000.xml @@ -75,9 +75,9 @@ - NList/activeNList_0.10_10000_2.xml - NList/inhNList_0.80_10000.xml - + configfiles/NList/activeNList_0.10_10000_2.xml + configfiles/NList/inhNList_0.80_10000.xml + diff --git a/configfiles/tR_0.1--fE_0.90.xml b/configfiles/tR_0.1--fE_0.90.xml index be2f3791..0fcc57fb 100644 --- a/configfiles/tR_0.1--fE_0.90.xml +++ b/configfiles/tR_0.1--fE_0.90.xml @@ -75,9 +75,9 @@ - NList/activeNList_0.10.xml - NList/inhNList_0.90.xml - + configfiles/NList/activeNList_0.10.xml + configfiles/NList/inhNList_0.90.xml + diff --git a/configfiles/tR_0.1--fE_0.90_10000.xml b/configfiles/tR_0.1--fE_0.90_10000.xml index 89157d0f..c2fe3b3d 100644 --- a/configfiles/tR_0.1--fE_0.90_10000.xml +++ b/configfiles/tR_0.1--fE_0.90_10000.xml @@ -75,9 +75,9 @@ - NList/activeNList_0.10_10000.xml - NList/inhNList_0.90_10000.xml - + configfiles/NList/activeNList_0.10_10000.xml + configfiles/NList/inhNList_0.90_10000.xml + diff --git a/configfiles/test-large-conected.xml b/configfiles/test-large-conected.xml index b9e0359d..fb7d21f0 100644 --- a/configfiles/test-large-conected.xml +++ b/configfiles/test-large-conected.xml @@ -75,9 +75,9 @@ - NList/ActiveNList100x100-0.1.xml - NList/InhibitoryNList100x100-0.1.xml - NList/ProbedNList-empty.xml + configfiles/NList/ActiveNList100x100-0.1.xml + configfiles/NList/InhibitoryNList100x100-0.1.xml + diff --git a/configfiles/test-large-long.xml b/configfiles/test-large-long.xml index 7c3e2c30..507a7ab5 100644 --- a/configfiles/test-large-long.xml +++ b/configfiles/test-large-long.xml @@ -75,9 +75,9 @@ - NList/ActiveNList100x100-0.1.xml - NList/InhibitoryNList100x100-0.1.xml - NList/ProbedNList-empty.xml + configfiles/NList/ActiveNList100x100-0.1.xml + configfiles/NList/InhibitoryNList100x100-0.1.xml + diff --git a/configfiles/test-large-short.xml b/configfiles/test-large-short.xml index 23abaa04..c3b54adc 100644 --- a/configfiles/test-large-short.xml +++ b/configfiles/test-large-short.xml @@ -75,9 +75,9 @@ - NList/ActiveNList100x100-0.1.xml - NList/InhibitoryNList100x100-0.1.xml - NList/ProbedNList-empty.xml + configfiles/NList/ActiveNList100x100-0.1.xml + configfiles/NList/InhibitoryNList100x100-0.1.xml + diff --git a/configfiles/test-medium-100.xml b/configfiles/test-medium-100.xml index d6fe35d0..231848b8 100644 --- a/configfiles/test-medium-100.xml +++ b/configfiles/test-medium-100.xml @@ -75,9 +75,9 @@ - NList/ActiveNList30x30-0.01.xml - NList/InhibitoryNList30x30-0.02.xml - NList/ProbedNList-empty.xml + configfiles/NList/ActiveNList30x30-0.01.xml + configfiles/NList/InhibitoryNList30x30-0.02.xml + diff --git a/configfiles/test-medium-2.xml b/configfiles/test-medium-2.xml index fb422d48..6e381536 100644 --- a/configfiles/test-medium-2.xml +++ b/configfiles/test-medium-2.xml @@ -75,9 +75,9 @@ - NList/ActiveNList30x30-0.1.xml - NList/InhibitoryNList30x30-0.02.xml - NList/ProbedNList-empty.xml + configfiles/NList/ActiveNList30x30-0.1.xml + configfiles/NList/InhibitoryNList30x30-0.02.xml + diff --git a/configfiles/test-medium-500.xml b/configfiles/test-medium-500.xml index 5a8f50b9..0091f9d7 100644 --- a/configfiles/test-medium-500.xml +++ b/configfiles/test-medium-500.xml @@ -75,9 +75,9 @@ - NList/ActiveNList30x30-0.01.xml - NList/InhibitoryNList30x30-0.02.xml - NList/ProbedNList-empty.xml + configfiles/NList/ActiveNList30x30-0.01.xml + configfiles/NList/InhibitoryNList30x30-0.02.xml + diff --git a/configfiles/test-medium.xml b/configfiles/test-medium.xml index 3a5ebd3f..ae04e912 100644 --- a/configfiles/test-medium.xml +++ b/configfiles/test-medium.xml @@ -75,9 +75,9 @@ - NList/ActiveNList30x30-0.01.xml - NList/InhibitoryNList30x30-0.02.xml - NList/ProbedNList-empty.xml + /CSSDIV/students/stantp2/497/Nonproblem/BrainGrid-multi-clusters-sim/configfiles/NList/ActiveNList30x30-0.01.xml + /CSSDIV/students/stantp2/497/Nonproblem/BrainGrid-multi-clusters-sim/configfiles/NList/InhibitoryNList30x30-0.02.xml + diff --git a/configfiles/test-small-connected.xml b/configfiles/test-small-connected.xml index 828f6bef..49fe9478 100644 --- a/configfiles/test-small-connected.xml +++ b/configfiles/test-small-connected.xml @@ -75,9 +75,9 @@ - NList/ActiveNList10x10-0.1.xml - NList/InhibitoryNList10x10-0.02.xml - NList/ProbedNList-empty.xml + /CSSDIV/students/stantp2/497/BrainGrid/configfiles/NList/ActiveNList10x10-0.1.xml + /CSSDIV/students/stantp2/497/BrainGrid/configfiles/NList/InhibitoryNList10x10-0.02.xml + diff --git a/configfiles/test-small.xml b/configfiles/test-small.xml index faee5fff..224966ea 100644 --- a/configfiles/test-small.xml +++ b/configfiles/test-small.xml @@ -75,9 +75,9 @@ - NList/ActiveNList10x10-0.1.xml - NList/InhibitoryNList10x10-0.02.xml - NList/ProbedNList-empty.xml + /CSSDIV/students/stantp2/497/BrainGrid/configfiles/NList/ActiveNList10x10-0.1.xml + /CSSDIV/students/stantp2/497/BrainGrid/configfiles/NList/InhibitoryNList10x10-0.02.xml + diff --git a/configfiles/test-tiny.xml b/configfiles/test-tiny.xml index 49c85736..c1a4ef20 100644 --- a/configfiles/test-tiny.xml +++ b/configfiles/test-tiny.xml @@ -75,9 +75,9 @@ - NList/ActiveNList2x2.xml - NList/InhibitoryNList2x2.xml - NList/ProbedNList-empty.xml + /CSSDIV/students/stantp2/497/Nonproblem/BrainGrid-multi-clusters-sim/configfiles/NList/ActiveNList2x2.xml + configfiles/NList/InhibitoryNList2x2.xml + From d02ff22f7f8f7c1837874ca4e6aefe9fc3acf30f Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 29 Apr 2018 20:51:13 -0700 Subject: [PATCH 05/30] Update Cluster.cpp some debugging and cleanup. --- Core/Cluster.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 802d62c0..0a00889e 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -1,5 +1,6 @@ #include "Cluster.h" #include "ISInput.h" +#include // Initialize the Barrier Synchnonize object for advanceThreads. Barrier *Cluster::m_barrierAdvance = NULL; @@ -136,9 +137,10 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! - int myPid = thAdvance.getid(); - pthread_setaffinity_np(thAdvance, sizeof(cpu_set_t), &my_set); - cout << "thread " << " locked to core: " << assignedCore << endl; + pthread_setaffinity_np(thAdvance.native_handle(), sizeof(cpu_set_t), &my_set); + stringstream ss; + ss << thAdvance.get_id(); + cout << "thread " << ss.str() << " locked to core: " << assignedCore << endl; // Leave it running thAdvance.detach(); From bf1b7d5bbca17f845059a67892f87e3d74662cb7 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 29 Apr 2018 20:57:41 -0700 Subject: [PATCH 06/30] fix wrong variable. --- Core/Cluster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 802d62c0..e9180fef 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -138,7 +138,7 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! int myPid = thAdvance.getid(); pthread_setaffinity_np(thAdvance, sizeof(cpu_set_t), &my_set); - cout << "thread " << " locked to core: " << assignedCore << endl; + cout << "thread " << " locked to core: " << lockedCore << endl; // Leave it running thAdvance.detach(); From 52835a4addda602aab43fb976072151dbf029654 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 29 Apr 2018 20:59:51 -0700 Subject: [PATCH 07/30] fix --- Core/Cluster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 0a00889e..5fa7a5d5 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -140,7 +140,7 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c pthread_setaffinity_np(thAdvance.native_handle(), sizeof(cpu_set_t), &my_set); stringstream ss; ss << thAdvance.get_id(); - cout << "thread " << ss.str() << " locked to core: " << assignedCore << endl; + cout << "thread " << ss.str() << " locked to core: " << lockedCore << endl; // Leave it running thAdvance.detach(); From a44ca46e825607ca281c29dd96566e2ae5722d9b Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 13:30:00 -0700 Subject: [PATCH 08/30] print core ID's each epoch. --- Core/Cluster.cpp | 12 ++++++++++-- Core/Cluster.h | 3 +++ Core/IModel.h | 3 +++ Core/Model.cpp | 8 ++++++++ Core/Model.h | 3 +++ Core/Simulator.cpp | 3 ++- 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 5fa7a5d5..c54b8163 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -2,7 +2,7 @@ #include "ISInput.h" #include -// Initialize the Barrier Synchnonize object for advanceThreads. +// Initialize the Barrier Synchronize object for advanceThreads. Barrier *Cluster::m_barrierAdvance = NULL; // Initialize the flag for advanceThreads. true if terminating advanceThreads. @@ -11,6 +11,12 @@ bool Cluster::m_isAdvanceExit = false; // Initialize the synaptic transmission delay, descretized into time steps. int Cluster::m_nSynapticTransDelay = 0; +unsigned int threadID = 0; + +cpu_set_t internalSet; + +std::thread* threadReference = nullptr; + /* * Constructor */ @@ -136,10 +142,12 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c cpu_set_t my_set; //http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); + internalSet = my_set; std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! pthread_setaffinity_np(thAdvance.native_handle(), sizeof(cpu_set_t), &my_set); stringstream ss; - ss << thAdvance.get_id(); + ss << threadID << thAdvance.get_id(); + threadReference = thAdvance; cout << "thread " << ss.str() << " locked to core: " << lockedCore << endl; // Leave it running diff --git a/Core/Cluster.h b/Core/Cluster.h index dbedce70..ed1d9356 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -60,7 +60,10 @@ class Cluster public: Cluster(IAllNeurons *neurons, IAllSynapses *synapses); int assignedCore; + unsigned int threadID; virtual ~Cluster(); + cpu_set_t internalSet; + std::thread* threadReference; /** * Deserializes internal state from a prior run of the simulation. diff --git a/Core/IModel.h b/Core/IModel.h index 73e4fa2a..07ca411d 100644 --- a/Core/IModel.h +++ b/Core/IModel.h @@ -108,6 +108,9 @@ class IModel { * @param currentStep - The epoch step in which the connections are being updated. * @param sim_info - parameters defining the simulation to be run with the given collection of neurons. */ + + virtual void printThreadCoreData(); + virtual void updateConnections(const SimulationInfo *sim_info) = 0; /** diff --git a/Core/Model.cpp b/Core/Model.cpp index 787efd52..3e66a3e6 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -287,6 +287,14 @@ void Model::updateConnections(const SimulationInfo *sim_info) } } +void Model::printThreadCoreData(){ + //stuff + for (int i = 0; i < m_vtClr.size(); i++){ + cout << "Thread " << m_vtClr[i].threadID << " is running on core: " << pthread_getaffinity_np(m_vtClr[i].threadReference.native_handle(), + sizeOf(m_vtClr[i].internalSet, m_vtClr[i].interalSet)); + } +} + #if defined(PERFORMANCE_METRICS) /* diff --git a/Core/Model.h b/Core/Model.h index a9298d08..43510e14 100644 --- a/Core/Model.h +++ b/Core/Model.h @@ -93,6 +93,9 @@ class Model : public IModel * @param sim_info - parameters defining the simulation to be run with the given collection of neurons. * @param simRecorder Pointer to the simulation recordig object. */ + virtual void printThreadCoreData(); + + virtual void setupSim(SimulationInfo *sim_info); /** diff --git a/Core/Simulator.cpp b/Core/Simulator.cpp index 77a35d12..7eb98313 100644 --- a/Core/Simulator.cpp +++ b/Core/Simulator.cpp @@ -98,7 +98,8 @@ void Simulator::simulate(SimulationInfo *sim_info) // Main simulation loop - execute maxGrowthSteps for (int currentStep = 1; currentStep <= sim_info->maxSteps; currentStep++) { - + //grab cluster stuff here. + sim_info->model->printThreadCoreData(); DEBUG(cout << endl << endl;) DEBUG(cout << "Performing simulation number " << currentStep << endl;) DEBUG(cout << "Begin network state:" << endl;) From 614b742ee67798df22322ce0f7da8c05a2e285e8 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 16:05:32 -0700 Subject: [PATCH 09/30] more testing --- Core/Cluster.cpp | 4 ++-- Core/Cluster.h | 5 +++++ Core/Model.cpp | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index c54b8163..dd28e592 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -13,7 +13,7 @@ int Cluster::m_nSynapticTransDelay = 0; unsigned int threadID = 0; -cpu_set_t internalSet; +cpu_set_t internalSet = CPU_ZERO; std::thread* threadReference = nullptr; @@ -147,7 +147,7 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c pthread_setaffinity_np(thAdvance.native_handle(), sizeof(cpu_set_t), &my_set); stringstream ss; ss << threadID << thAdvance.get_id(); - threadReference = thAdvance; + threadReference = &thAdvance; cout << "thread " << ss.str() << " locked to core: " << lockedCore << endl; // Leave it running diff --git a/Core/Cluster.h b/Core/Cluster.h index ed1d9356..fad9da0d 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -171,6 +171,11 @@ class Cluster * @param sim_info SimulationInfo class to read information from. * @param iStep Simulation steps to advance. */ + + static unsigned int getThreadID() { + return threadID; + } + static void runAdvance(const SimulationInfo *sim_info, int iStep); /** diff --git a/Core/Model.cpp b/Core/Model.cpp index 3e66a3e6..46023e07 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -289,9 +289,10 @@ void Model::updateConnections(const SimulationInfo *sim_info) void Model::printThreadCoreData(){ //stuff - for (int i = 0; i < m_vtClr.size(); i++){ - cout << "Thread " << m_vtClr[i].threadID << " is running on core: " << pthread_getaffinity_np(m_vtClr[i].threadReference.native_handle(), + for (unsigned i = 0; i < m_vtClr.size(); i++){ + cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i].threadReference.native_handle(), sizeOf(m_vtClr[i].internalSet, m_vtClr[i].interalSet)); + } } From 67bcdcd43d9fdff936a4c3d683046ef9b4c89666 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 16:27:48 -0700 Subject: [PATCH 10/30] more changes. --- Core/Cluster.cpp | 10 +++++++++- Core/Cluster.h | 6 +++--- Core/Model.cpp | 6 ++++-- Core/Model.h | 3 +++ 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index dd28e592..bc47bc46 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -1,6 +1,9 @@ #include "Cluster.h" #include "ISInput.h" #include +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include + // Initialize the Barrier Synchronize object for advanceThreads. Barrier *Cluster::m_barrierAdvance = NULL; @@ -13,7 +16,7 @@ int Cluster::m_nSynapticTransDelay = 0; unsigned int threadID = 0; -cpu_set_t internalSet = CPU_ZERO; +cpu_set_t internalSet; std::thread* threadReference = nullptr; @@ -120,6 +123,10 @@ void Cluster::cleanupCluster(SimulationInfo *sim_info, ClusterInfo *clr_info) m_synapses->cleanupSynapses(); } +unsigned int Cluster::getThreadID() { + return threadID; +} + /* * Create an advanceThread. * If barrier synchronize object has not been created, create it. @@ -139,6 +146,7 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c // Create an advanceThread int lockedCore = clr_info->assignedCore; + CPU_ZERO(&internalSet); cpu_set_t my_set; //http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); diff --git a/Core/Cluster.h b/Core/Cluster.h index fad9da0d..595f511a 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -54,6 +54,8 @@ #include #include "Barrier.hpp" #include +#define _GNU_SOURCE /* See feature_test_macros(7) */ + class Cluster { @@ -172,9 +174,7 @@ class Cluster * @param iStep Simulation steps to advance. */ - static unsigned int getThreadID() { - return threadID; - } + static unsigned int getThreadID(); static void runAdvance(const SimulationInfo *sim_info, int iStep); diff --git a/Core/Model.cpp b/Core/Model.cpp index 46023e07..2e933a29 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -5,6 +5,8 @@ #include "ParseParamError.h" #include "Util.h" #include "ConnGrowth.h" +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include #include "ISInput.h" #if defined(USE_GPU) #include "GPUSpikingCluster.h" @@ -290,8 +292,8 @@ void Model::updateConnections(const SimulationInfo *sim_info) void Model::printThreadCoreData(){ //stuff for (unsigned i = 0; i < m_vtClr.size(); i++){ - cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i].threadReference.native_handle(), - sizeOf(m_vtClr[i].internalSet, m_vtClr[i].interalSet)); + cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i]->threadReference->native_handle(), + sizeOf(m_vtClr[i]->internalSet, m_vtClr[i]->interalSet)); } } diff --git a/Core/Model.h b/Core/Model.h index 43510e14..e030e5f8 100644 --- a/Core/Model.h +++ b/Core/Model.h @@ -51,6 +51,9 @@ #include #include +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#include + using namespace std; From 1017f2924385ea8d4964182458bddfa92ff0fb72 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 16:37:48 -0700 Subject: [PATCH 11/30] rewrite getting internal set. --- Core/Cluster.cpp | 4 ---- Core/Cluster.h | 3 +-- Core/Model.cpp | 7 ++++++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index bc47bc46..5aaaf7d6 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -16,8 +16,6 @@ int Cluster::m_nSynapticTransDelay = 0; unsigned int threadID = 0; -cpu_set_t internalSet; - std::thread* threadReference = nullptr; /* @@ -146,11 +144,9 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c // Create an advanceThread int lockedCore = clr_info->assignedCore; - CPU_ZERO(&internalSet); cpu_set_t my_set; //http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); - internalSet = my_set; std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! pthread_setaffinity_np(thAdvance.native_handle(), sizeof(cpu_set_t), &my_set); stringstream ss; diff --git a/Core/Cluster.h b/Core/Cluster.h index 595f511a..294e43a2 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -64,7 +64,6 @@ class Cluster int assignedCore; unsigned int threadID; virtual ~Cluster(); - cpu_set_t internalSet; std::thread* threadReference; /** @@ -174,7 +173,7 @@ class Cluster * @param iStep Simulation steps to advance. */ - static unsigned int getThreadID(); + unsigned int getThreadID(); static void runAdvance(const SimulationInfo *sim_info, int iStep); diff --git a/Core/Model.cpp b/Core/Model.cpp index 2e933a29..948eb756 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -292,8 +292,13 @@ void Model::updateConnections(const SimulationInfo *sim_info) void Model::printThreadCoreData(){ //stuff for (unsigned i = 0; i < m_vtClr.size(); i++){ + + cpu_set_t internalSet; + CPU_ZERO(&internalSet); + CPU_SET(m_vtClrInfo[i]->assignedCore, internalSet); + cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i]->threadReference->native_handle(), - sizeOf(m_vtClr[i]->internalSet, m_vtClr[i]->interalSet)); + sizeOf(internalSet, internalSet)); } } From 6c8d6f54237e00386a106ffb5448a0b633b33c85 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 16:50:35 -0700 Subject: [PATCH 12/30] another increment. --- Core/Model.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Model.cpp b/Core/Model.cpp index 948eb756..fcd52e3d 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -295,10 +295,10 @@ void Model::printThreadCoreData(){ cpu_set_t internalSet; CPU_ZERO(&internalSet); - CPU_SET(m_vtClrInfo[i]->assignedCore, internalSet); + CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); - cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i]->threadReference->native_handle(), - sizeOf(internalSet, internalSet)); + cout << "Thread " << m_vtClr[i].getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i].threadReference->native_handle(), + sizeOf(internalSet, &internalSet)); } } From 92ac1ccf0062892a1ba2adf3ab369acfee31d436 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 16:57:56 -0700 Subject: [PATCH 13/30] include iostream, fix pointers. --- Core/Model.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/Model.cpp b/Core/Model.cpp index fcd52e3d..920c065c 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -8,6 +8,7 @@ #define _GNU_SOURCE /* See feature_test_macros(7) */ #include #include "ISInput.h" +#include #if defined(USE_GPU) #include "GPUSpikingCluster.h" #endif @@ -297,7 +298,7 @@ void Model::printThreadCoreData(){ CPU_ZERO(&internalSet); CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); - cout << "Thread " << m_vtClr[i].getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i].threadReference->native_handle(), + cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i]->threadReference->native_handle(), sizeOf(internalSet, &internalSet)); } From b3eace0a11237b65805fc212cef48a211fca865c Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 17:03:56 -0700 Subject: [PATCH 14/30] fixed the stupid typo that has been causing me problems. --- Core/Cluster.cpp | 1 - Core/Cluster.h | 1 - Core/Model.cpp | 3 +-- Core/Model.h | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 5aaaf7d6..b44206e4 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -1,7 +1,6 @@ #include "Cluster.h" #include "ISInput.h" #include -#define _GNU_SOURCE /* See feature_test_macros(7) */ #include diff --git a/Core/Cluster.h b/Core/Cluster.h index 294e43a2..38ead5a6 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -54,7 +54,6 @@ #include #include "Barrier.hpp" #include -#define _GNU_SOURCE /* See feature_test_macros(7) */ class Cluster diff --git a/Core/Model.cpp b/Core/Model.cpp index 920c065c..ebd5dd25 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -5,7 +5,6 @@ #include "ParseParamError.h" #include "Util.h" #include "ConnGrowth.h" -#define _GNU_SOURCE /* See feature_test_macros(7) */ #include #include "ISInput.h" #include @@ -299,7 +298,7 @@ void Model::printThreadCoreData(){ CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i]->threadReference->native_handle(), - sizeOf(internalSet, &internalSet)); + sizeof(internalSet, &internalSet)); } } diff --git a/Core/Model.h b/Core/Model.h index e030e5f8..bab504ca 100644 --- a/Core/Model.h +++ b/Core/Model.h @@ -51,7 +51,6 @@ #include #include -#define _GNU_SOURCE /* See feature_test_macros(7) */ #include From 5e2d4bc2acb683e94ff09c8f07acea7ce3243f59 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 17:11:31 -0700 Subject: [PATCH 15/30] this should compile --- Core/Model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/Model.cpp b/Core/Model.cpp index ebd5dd25..a87e6071 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -298,7 +298,7 @@ void Model::printThreadCoreData(){ CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i]->threadReference->native_handle(), - sizeof(internalSet, &internalSet)); + sizeof(internalSet,&internalSet), &internalSet); } } From 6dfd8161c8ba34a96a7f56a05a7921e99660709d Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 17:22:26 -0700 Subject: [PATCH 16/30] stuff. --- Core/IModel.h | 2 +- Core/Model.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/IModel.h b/Core/IModel.h index 07ca411d..aa525aa5 100644 --- a/Core/IModel.h +++ b/Core/IModel.h @@ -109,7 +109,7 @@ class IModel { * @param sim_info - parameters defining the simulation to be run with the given collection of neurons. */ - virtual void printThreadCoreData(); + virtual void printThreadCoreData() = 0; virtual void updateConnections(const SimulationInfo *sim_info) = 0; diff --git a/Core/Model.h b/Core/Model.h index bab504ca..81c60c17 100644 --- a/Core/Model.h +++ b/Core/Model.h @@ -95,8 +95,6 @@ class Model : public IModel * @param sim_info - parameters defining the simulation to be run with the given collection of neurons. * @param simRecorder Pointer to the simulation recordig object. */ - virtual void printThreadCoreData(); - virtual void setupSim(SimulationInfo *sim_info); @@ -112,6 +110,10 @@ class Model : public IModel * * @return Pointer to the Connections class object. */ + + virtual void printThreadCoreData(); + + virtual Connections* getConnections(); /** From c8fb03885bd230aaaddee13770651072a92dcab4 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Fri, 11 May 2018 17:36:27 -0700 Subject: [PATCH 17/30] fix display stuff. --- Core/Cluster.cpp | 2 +- Core/Cluster.h | 2 +- Core/Model.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index b44206e4..e8bc852c 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -13,7 +13,7 @@ bool Cluster::m_isAdvanceExit = false; // Initialize the synaptic transmission delay, descretized into time steps. int Cluster::m_nSynapticTransDelay = 0; -unsigned int threadID = 0; +unsigned long threadID = 0; std::thread* threadReference = nullptr; diff --git a/Core/Cluster.h b/Core/Cluster.h index 38ead5a6..af91235c 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -61,7 +61,7 @@ class Cluster public: Cluster(IAllNeurons *neurons, IAllSynapses *synapses); int assignedCore; - unsigned int threadID; + unsigned long threadID; virtual ~Cluster(); std::thread* threadReference; diff --git a/Core/Model.cpp b/Core/Model.cpp index a87e6071..0ad95be7 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -298,7 +298,7 @@ void Model::printThreadCoreData(){ CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i]->threadReference->native_handle(), - sizeof(internalSet,&internalSet), &internalSet); + sizeof(internalSet,&internalSet), &internalSet) << endl; } } From 72faba3a45e8349c89064258d0a58148973a5707 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 13 May 2018 14:51:39 -0700 Subject: [PATCH 18/30] more debugging. --- Core/Cluster.cpp | 2 ++ Core/Cluster.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index e8bc852c..49e42547 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -152,6 +152,8 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c ss << threadID << thAdvance.get_id(); threadReference = &thAdvance; cout << "thread " << ss.str() << " locked to core: " << lockedCore << endl; + cout << "CONFIRMATION THREAD " << threadReference->get_id() << " is running on core " << + pthread_getaffinity_np(threadReference->native_handle(),sizeof(cpu_set_t), &my_set) << endl; // Leave it running thAdvance.detach(); diff --git a/Core/Cluster.h b/Core/Cluster.h index af91235c..d0077095 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -63,7 +63,7 @@ class Cluster int assignedCore; unsigned long threadID; virtual ~Cluster(); - std::thread* threadReference; + std::thread threadReference; /** * Deserializes internal state from a prior run of the simulation. From 06d989d6f692583cd0b9bee8d1221975eeed4383 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 13 May 2018 15:18:20 -0700 Subject: [PATCH 19/30] fix errors, change functions. --- Core/Cluster.cpp | 8 +++++--- Core/Cluster.h | 2 +- Core/Model.cpp | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 49e42547..d44d088f 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -147,13 +147,15 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! - pthread_setaffinity_np(thAdvance.native_handle(), sizeof(cpu_set_t), &my_set); + sched_setaffinity(thAdvance.native_handle(), sizeof(cpu_set_t), &my_set); stringstream ss; ss << threadID << thAdvance.get_id(); threadReference = &thAdvance; cout << "thread " << ss.str() << " locked to core: " << lockedCore << endl; - cout << "CONFIRMATION THREAD " << threadReference->get_id() << " is running on core " << - pthread_getaffinity_np(threadReference->native_handle(),sizeof(cpu_set_t), &my_set) << endl; + stringstream tt; + threadReference->get_id(); + cout << "CONFIRMATION THREAD " << tt.str() << " is running on core " << + sched_setaffinity(threadReference->native_handle(),sizeof(cpu_set_t), &my_set) << endl; // Leave it running thAdvance.detach(); diff --git a/Core/Cluster.h b/Core/Cluster.h index d0077095..af91235c 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -63,7 +63,7 @@ class Cluster int assignedCore; unsigned long threadID; virtual ~Cluster(); - std::thread threadReference; + std::thread* threadReference; /** * Deserializes internal state from a prior run of the simulation. diff --git a/Core/Model.cpp b/Core/Model.cpp index 0ad95be7..565172d3 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -297,7 +297,7 @@ void Model::printThreadCoreData(){ CPU_ZERO(&internalSet); CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); - cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << pthread_getaffinity_np(m_vtClr[i]->threadReference->native_handle(), + cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << sched_setaffinity(m_vtClr[i]->threadReference->native_handle(), sizeof(internalSet,&internalSet), &internalSet) << endl; } From a02682e913b8df4fceb7091bcd6caf9e6e21b462 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 13 May 2018 15:42:13 -0700 Subject: [PATCH 20/30] change to getpid() with includes. --- Core/Cluster.cpp | 11 +++++++---- Core/Cluster.h | 3 +++ Core/Model.cpp | 7 +++++-- Core/Model.h | 3 +++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index d44d088f..796f722d 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -2,6 +2,9 @@ #include "ISInput.h" #include #include +#include +#include + // Initialize the Barrier Synchronize object for advanceThreads. @@ -147,15 +150,15 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! - sched_setaffinity(thAdvance.native_handle(), sizeof(cpu_set_t), &my_set); + sched_setaffinity(thAdvance.getpid(), sizeof(cpu_set_t), &my_set); stringstream ss; - ss << threadID << thAdvance.get_id(); + ss << threadID << thAdvance.getpid(); threadReference = &thAdvance; cout << "thread " << ss.str() << " locked to core: " << lockedCore << endl; stringstream tt; - threadReference->get_id(); + threadReference->getpid(); cout << "CONFIRMATION THREAD " << tt.str() << " is running on core " << - sched_setaffinity(threadReference->native_handle(),sizeof(cpu_set_t), &my_set) << endl; + sched_getaffinity(threadReference->getpid(),sizeof(cpu_set_t), &my_set) << endl; // Leave it running thAdvance.detach(); diff --git a/Core/Cluster.h b/Core/Cluster.h index af91235c..ff9a1ed4 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -54,6 +54,9 @@ #include #include "Barrier.hpp" #include +#include +#include + class Cluster diff --git a/Core/Model.cpp b/Core/Model.cpp index 565172d3..9d54e3b5 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -8,6 +8,9 @@ #include #include "ISInput.h" #include +#include +#include + #if defined(USE_GPU) #include "GPUSpikingCluster.h" #endif @@ -297,8 +300,8 @@ void Model::printThreadCoreData(){ CPU_ZERO(&internalSet); CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); - cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << sched_setaffinity(m_vtClr[i]->threadReference->native_handle(), - sizeof(internalSet,&internalSet), &internalSet) << endl; + cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << sched_setaffinity(m_vtClr[i]->threadReference->getpid(), + sizeof(internalSet), &internalSet) << endl; } } diff --git a/Core/Model.h b/Core/Model.h index 81c60c17..6a31b1ab 100644 --- a/Core/Model.h +++ b/Core/Model.h @@ -52,6 +52,9 @@ #include #include #include +#include +#include + using namespace std; From a14fe3f0d537145b72021bce2a152de41b1c349b Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 13 May 2018 16:49:31 -0700 Subject: [PATCH 21/30] trying another approach with a helper function. --- Core/Cluster.cpp | 17 ++++++++++++----- Core/Cluster.h | 6 ++++++ Core/Model.cpp | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 796f722d..88034ea6 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -20,6 +20,8 @@ unsigned long threadID = 0; std::thread* threadReference = nullptr; +pid_t mypidt; + /* * Constructor */ @@ -149,21 +151,26 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c cpu_set_t my_set; //http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); - std::thread thAdvance(&Cluster::advanceThread, this, sim_info, clr_info); //Schedule this! - sched_setaffinity(thAdvance.getpid(), sizeof(cpu_set_t), &my_set); + std::thread thAdvance(&Cluster::processAdvanceThread, this, sim_info, clr_info); //Schedule this! + sched_setaffinity(mypidt, sizeof(cpu_set_t), &my_set); stringstream ss; - ss << threadID << thAdvance.getpid(); + ss << threadID << mypidt; threadReference = &thAdvance; cout << "thread " << ss.str() << " locked to core: " << lockedCore << endl; stringstream tt; - threadReference->getpid(); + threadReference->mypidt; cout << "CONFIRMATION THREAD " << tt.str() << " is running on core " << - sched_getaffinity(threadReference->getpid(),sizeof(cpu_set_t), &my_set) << endl; + sched_getaffinity(threadReference->mypidt,sizeof(cpu_set_t), &my_set) << endl; // Leave it running thAdvance.detach(); } +void Cluster::processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info) { + mypidt = syscall(__NR_gettid); + advanceThread(*sim_info, *clr_info); +} + /* * Thread for advance a cluster. * diff --git a/Core/Cluster.h b/Core/Cluster.h index ff9a1ed4..b96c3ba4 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -68,6 +68,8 @@ class Cluster virtual ~Cluster(); std::thread* threadReference; + pid_t mypidt; + /** * Deserializes internal state from a prior run of the simulation. * This allows simulations to be continued from a particular point, to be restarted, or to be @@ -166,6 +168,10 @@ class Cluster * @param sim_info SimulationInfo class to read information from. * @param clr_info ClusterInfo class to read information from. */ + + void processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info); + + void advanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info); /** diff --git a/Core/Model.cpp b/Core/Model.cpp index 9d54e3b5..8832ad13 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -300,7 +300,7 @@ void Model::printThreadCoreData(){ CPU_ZERO(&internalSet); CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); - cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << sched_setaffinity(m_vtClr[i]->threadReference->getpid(), + cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << sched_getaffinity(m_vtClr[i]->mypidt, sizeof(internalSet), &internalSet) << endl; } From 846efb4aa0f353b7e4430af8b63228441dab84aa Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sun, 13 May 2018 17:06:18 -0700 Subject: [PATCH 22/30] more stuff. --- Core/Cluster.cpp | 17 +++++------------ Core/Cluster.h | 3 --- Core/Model.cpp | 2 +- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 88034ea6..6a2349c9 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -125,10 +125,6 @@ void Cluster::cleanupCluster(SimulationInfo *sim_info, ClusterInfo *clr_info) m_synapses->cleanupSynapses(); } -unsigned int Cluster::getThreadID() { - return threadID; -} - /* * Create an advanceThread. * If barrier synchronize object has not been created, create it. @@ -152,15 +148,12 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); std::thread thAdvance(&Cluster::processAdvanceThread, this, sim_info, clr_info); //Schedule this! + cout << "mypidt is now " << mypidt << endl; sched_setaffinity(mypidt, sizeof(cpu_set_t), &my_set); - stringstream ss; - ss << threadID << mypidt; threadReference = &thAdvance; - cout << "thread " << ss.str() << " locked to core: " << lockedCore << endl; - stringstream tt; - threadReference->mypidt; - cout << "CONFIRMATION THREAD " << tt.str() << " is running on core " << - sched_getaffinity(threadReference->mypidt,sizeof(cpu_set_t), &my_set) << endl; + cout << "thread " << mypidt << " locked to core: " << lockedCore << endl; + cout << "CONFIRMATION THREAD " << mypidt << " is running on core " << + sched_getaffinity(mypidt,sizeof(cpu_set_t), &my_set) << endl; // Leave it running thAdvance.detach(); @@ -168,7 +161,7 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c void Cluster::processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info) { mypidt = syscall(__NR_gettid); - advanceThread(*sim_info, *clr_info); + advanceThread(sim_info, clr_info); } /* diff --git a/Core/Cluster.h b/Core/Cluster.h index b96c3ba4..c71ffb30 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -64,7 +64,6 @@ class Cluster public: Cluster(IAllNeurons *neurons, IAllSynapses *synapses); int assignedCore; - unsigned long threadID; virtual ~Cluster(); std::thread* threadReference; @@ -181,8 +180,6 @@ class Cluster * @param iStep Simulation steps to advance. */ - unsigned int getThreadID(); - static void runAdvance(const SimulationInfo *sim_info, int iStep); /** diff --git a/Core/Model.cpp b/Core/Model.cpp index 8832ad13..806ba006 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -300,7 +300,7 @@ void Model::printThreadCoreData(){ CPU_ZERO(&internalSet); CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); - cout << "Thread " << m_vtClr[i]->getThreadID() << " is running on core: " << sched_getaffinity(m_vtClr[i]->mypidt, + cout << "Thread " << m_vtClr[i]->mypidt << " is running on core: " << sched_getaffinity(m_vtClr[i]->mypidt, sizeof(internalSet), &internalSet) << endl; } From 03346d3e773364cc19420b2eaf3885245b092233 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Tue, 15 May 2018 13:57:41 -0700 Subject: [PATCH 23/30] mutex, move scheduling to helper function for internal scheduling. --- Core/Cluster.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- Core/Cluster.h | 9 +++++++-- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 6a2349c9..1be8aae7 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -4,6 +4,9 @@ #include #include #include +#include +#include + @@ -22,6 +25,14 @@ std::thread* threadReference = nullptr; pid_t mypidt; +bool doneID = false; +bool ready = false; + +mutex m; + +condition_variable cv; + + /* * Constructor */ @@ -147,9 +158,22 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c cpu_set_t my_set; //http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html CPU_ZERO(&my_set); //https://stackoverflow.com/questions/10490756/how-to-use-sched-getaffinity2-and-sched-setaffinity2-please-give-code-samp CPU_SET(lockedCore, &my_set); - std::thread thAdvance(&Cluster::processAdvanceThread, this, sim_info, clr_info); //Schedule this! + std::thread thAdvance(&Cluster::processAdvanceThread, this, sim_info, clr_info, my_set); //Schedule this! + + { + std::lock_guard lk(m); + ready = true; + std::cout << "main() signals data ready for processing\n"; + } + cv.notify_one(); + + { + std::unique_lock lk(m); + cv.wait(lk, []{return processed;}); + } + + cout << "mypidt is now " << mypidt << endl; - sched_setaffinity(mypidt, sizeof(cpu_set_t), &my_set); threadReference = &thAdvance; cout << "thread " << mypidt << " locked to core: " << lockedCore << endl; cout << "CONFIRMATION THREAD " << mypidt << " is running on core " << @@ -159,8 +183,21 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c thAdvance.detach(); } -void Cluster::processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info) { +void Cluster::processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info, cpu_set_t my_set) { + std::unique_lock lk(m); + cv.wait(lk, []{return ready;}); + mypidt = syscall(__NR_gettid); + + doneID = true; + sched_setaffinity(mypidt, sizeof(cpu_set_t), &my_set); + + + lk.unlock(); + cv.notify_one(); + + + advanceThread(sim_info, clr_info); } diff --git a/Core/Cluster.h b/Core/Cluster.h index c71ffb30..93f78ac4 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -66,8 +66,13 @@ class Cluster int assignedCore; virtual ~Cluster(); std::thread* threadReference; + bool doneID; + cool ready; + mutex m; + condition_variable cv; - pid_t mypidt; + + pid_t mypidt; /** * Deserializes internal state from a prior run of the simulation. @@ -168,7 +173,7 @@ class Cluster * @param clr_info ClusterInfo class to read information from. */ - void processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info); + void processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info, cpu_set_t my_set); void advanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info); From 175df9e4e7b545a687afe2660d578f377ac5020c Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Tue, 15 May 2018 14:29:36 -0700 Subject: [PATCH 24/30] fix mutex stuff. --- Core/Cluster.cpp | 13 +++++++------ Core/Cluster.h | 6 ++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 1be8aae7..53b88d3a 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -6,6 +6,7 @@ #include #include #include +#include @@ -25,13 +26,13 @@ std::thread* threadReference = nullptr; pid_t mypidt; -bool doneID = false; -bool ready = false; - mutex m; condition_variable cv; +bool ready = false; +bool done = false; + /* * Constructor @@ -160,16 +161,16 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c CPU_SET(lockedCore, &my_set); std::thread thAdvance(&Cluster::processAdvanceThread, this, sim_info, clr_info, my_set); //Schedule this! + { std::lock_guard lk(m); ready = true; std::cout << "main() signals data ready for processing\n"; } - cv.notify_one(); - + cv.notify_one; { std::unique_lock lk(m); - cv.wait(lk, []{return processed;}); + cv.wait(lk, []{return done;}); } diff --git a/Core/Cluster.h b/Core/Cluster.h index 93f78ac4..9c1912fe 100644 --- a/Core/Cluster.h +++ b/Core/Cluster.h @@ -56,6 +56,7 @@ #include #include #include +#include @@ -66,11 +67,12 @@ class Cluster int assignedCore; virtual ~Cluster(); std::thread* threadReference; - bool doneID; - cool ready; mutex m; condition_variable cv; + bool ready; + bool done; + pid_t mypidt; From 42ba0264ca59a1e05f225196f04cfbf9246f31cc Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Tue, 15 May 2018 14:37:10 -0700 Subject: [PATCH 25/30] fix some typos. --- Core/Cluster.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 53b88d3a..a55dad2e 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -167,10 +167,10 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c ready = true; std::cout << "main() signals data ready for processing\n"; } - cv.notify_one; + cv.notify_one(); { std::unique_lock lk(m); - cv.wait(lk, []{return done;}); + cv.wait(lk, [&]{return done;}); } @@ -186,11 +186,11 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c void Cluster::processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *clr_info, cpu_set_t my_set) { std::unique_lock lk(m); - cv.wait(lk, []{return ready;}); + cv.wait(lk, [&]{return ready;}); mypidt = syscall(__NR_gettid); - doneID = true; + done = true; sched_setaffinity(mypidt, sizeof(cpu_set_t), &my_set); From 7c5c8d0020cc34aad5d39b7a4c3b36a82060b5aa Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Thu, 17 May 2018 12:31:47 -0700 Subject: [PATCH 26/30] Add files via upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit upload edited files from Cerberus. I really should just make use of git but ¯\_(ツ)_/¯ --- Core/Cluster.cpp | 17 ++++++++++++----- Core/Model.cpp | 11 +++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index a55dad2e..1d1cfc5e 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -165,7 +165,7 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c { std::lock_guard lk(m); ready = true; - std::cout << "main() signals data ready for processing\n"; + std::cout << "main thread signals AdvanceThread\n"; } cv.notify_one(); { @@ -176,10 +176,16 @@ void Cluster::createAdvanceThread(const SimulationInfo *sim_info, ClusterInfo *c cout << "mypidt is now " << mypidt << endl; threadReference = &thAdvance; - cout << "thread " << mypidt << " locked to core: " << lockedCore << endl; - cout << "CONFIRMATION THREAD " << mypidt << " is running on core " << - sched_getaffinity(mypidt,sizeof(cpu_set_t), &my_set) << endl; + // cout << "thread " << mypidt << " locked to core: " << lockedCore << endl; + // cout << "CONFIRMATION THREAD " << mypidt << " is running on core " << + int success = sched_getaffinity(mypidt,sizeof(cpu_set_t), &my_set); + + for(int i = 0; i <= 16; i++) { + if(CPU_ISSET(i, &my_set) == 1) { + cout << "Core " << i << " member of this mask? " << CPU_ISSET(i, &my_set) << endl; + } + } // Leave it running thAdvance.detach(); } @@ -188,11 +194,12 @@ void Cluster::processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo * std::unique_lock lk(m); cv.wait(lk, [&]{return ready;}); - mypidt = syscall(__NR_gettid); + mypidt = syscall(SYS_gettid); done = true; sched_setaffinity(mypidt, sizeof(cpu_set_t), &my_set); + cout << "Set thread to core is finished for " << mypidt << " total cores " << CPU_COUNT(& my_set) << endl; lk.unlock(); cv.notify_one(); diff --git a/Core/Model.cpp b/Core/Model.cpp index 806ba006..7548249e 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -298,11 +298,14 @@ void Model::printThreadCoreData(){ cpu_set_t internalSet; CPU_ZERO(&internalSet); - CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); - - cout << "Thread " << m_vtClr[i]->mypidt << " is running on core: " << sched_getaffinity(m_vtClr[i]->mypidt, - sizeof(internalSet), &internalSet) << endl; + // CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); + sched_getaffinity(m_vtClr[i]->mypidt, sizeof(internalSet), &internalSet); + for(int j = 0; j <= 16; j++) { + if(CPU_ISSET(j, &internalSet)) { + cout << "Cluster " << i << " is running on core " << j << endl; + } + } } } From 5e5cc70349e8c7325c6c6c3903a665d52f08c692 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Thu, 7 Jun 2018 13:09:00 -0700 Subject: [PATCH 27/30] Update Model.cpp delete extraneous comment. --- Core/Model.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Core/Model.cpp b/Core/Model.cpp index 7548249e..3c0726ab 100644 --- a/Core/Model.cpp +++ b/Core/Model.cpp @@ -293,13 +293,11 @@ void Model::updateConnections(const SimulationInfo *sim_info) } void Model::printThreadCoreData(){ - //stuff for (unsigned i = 0; i < m_vtClr.size(); i++){ cpu_set_t internalSet; CPU_ZERO(&internalSet); - // CPU_SET(m_vtClrInfo[i]->assignedCore, &internalSet); - + sched_getaffinity(m_vtClr[i]->mypidt, sizeof(internalSet), &internalSet); for(int j = 0; j <= 16; j++) { if(CPU_ISSET(j, &internalSet)) { From 3a2946d278b6c7b32e3b729dc919d9bfee39bd36 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Thu, 7 Jun 2018 13:15:37 -0700 Subject: [PATCH 28/30] Update Cluster.cpp remove white space. --- Core/Cluster.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/Core/Cluster.cpp b/Core/Cluster.cpp index 1d1cfc5e..6d56529a 100644 --- a/Core/Cluster.cpp +++ b/Core/Cluster.cpp @@ -203,9 +203,6 @@ void Cluster::processAdvanceThread(const SimulationInfo *sim_info, ClusterInfo * lk.unlock(); cv.notify_one(); - - - advanceThread(sim_info, clr_info); } From cc570162cec1657bf860ee1872d69add0ef5ab55 Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sat, 9 Jun 2018 15:14:10 -0700 Subject: [PATCH 29/30] Delete Project.xml delete jetbrains file. --- .idea/codeStyles/Project.xml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .idea/codeStyles/Project.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 30aa626c..00000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file From f517d435be9f53479ed331728e924f64e3d0c89f Mon Sep 17 00:00:00 2001 From: Peter Stanton Date: Sat, 9 Jun 2018 15:14:23 -0700 Subject: [PATCH 30/30] Delete vcs.xml delete jetbrains --- .idea/vcs.xml | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file