Skip to content

Commit cda0cb0

Browse files
author
Henry Qin
committed
Rename CoreManager-->CorePolicy
1 parent f1a4e83 commit cda0cb0

File tree

11 files changed

+152
-152
lines changed

11 files changed

+152
-152
lines changed

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CHECK_TARGET=$$(find $(SRC_DIR) $(WRAPPER_DIR) '(' -name '*.h' -or -name '*.cc'
3131
endif
3232

3333
# Conversion to fully qualified names
34-
OBJECT_NAMES := Arachne.o Logger.o PerfStats.o DefaultCoreManager.o CoreLoadEstimator.o arachne_wrapper.o
34+
OBJECT_NAMES := Arachne.o Logger.o PerfStats.o DefaultCorePolicy.o CoreLoadEstimator.o arachne_wrapper.o
3535

3636
OBJECTS = $(patsubst %,$(OBJECT_DIR)/%,$(OBJECT_NAMES))
3737
HEADERS= $(shell find $(SRC_DIR) $(WRAPPER_DIR) -name '*.h')
@@ -81,11 +81,11 @@ CTEST_LIBS=-Lobj/ -lArachne
8181
INCLUDE+=-I${GTEST_DIR}/include -I${GMOCK_DIR}/include
8282
COREARBITER_BIN=$(COREARBITER)/bin/coreArbiterServer
8383

84-
test: $(OBJECT_DIR)/ArachneTest $(OBJECT_DIR)/CoreManagerTest $(OBJECT_DIR)/DefaultCoreManagerTest $(OBJECT_DIR)/arachne_wrapper_test
84+
test: $(OBJECT_DIR)/ArachneTest $(OBJECT_DIR)/CorePolicyTest $(OBJECT_DIR)/DefaultCorePolicyTest $(OBJECT_DIR)/arachne_wrapper_test
8585
$(OBJECT_DIR)/ArachneTest
86-
$(OBJECT_DIR)/DefaultCoreManagerTest
86+
$(OBJECT_DIR)/DefaultCorePolicyTest
8787
$(OBJECT_DIR)/arachne_wrapper_test
88-
$(OBJECT_DIR)/CoreManagerTest
88+
$(OBJECT_DIR)/CorePolicyTest
8989

9090
ctest: $(OBJECT_DIR)/arachne_wrapper_ctest
9191
$(OBJECT_DIR)/arachne_wrapper_ctest
@@ -99,10 +99,10 @@ $(OBJECT_DIR)/arachne_wrapper_test: $(OBJECT_DIR)/arachne_wrapper_test.o $(OBJEC
9999
$(OBJECT_DIR)/ArachneTest: $(OBJECT_DIR)/ArachneTest.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
100100
$(CXX) $(INCLUDE) $(CXXFLAGS) $< $(GTEST_DIR)/src/gtest_main.cc $(TEST_LIBS) $(LIBS) -o $@
101101

102-
$(OBJECT_DIR)/DefaultCoreManagerTest: $(OBJECT_DIR)/DefaultCoreManagerTest.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
102+
$(OBJECT_DIR)/DefaultCorePolicyTest: $(OBJECT_DIR)/DefaultCorePolicyTest.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
103103
$(CXX) $(INCLUDE) $(CXXFLAGS) $< $(GTEST_DIR)/src/gtest_main.cc $(TEST_LIBS) $(LIBS) -o $@
104104

105-
$(OBJECT_DIR)/CoreManagerTest: $(OBJECT_DIR)/CoreManagerTest.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
105+
$(OBJECT_DIR)/CorePolicyTest: $(OBJECT_DIR)/CorePolicyTest.o $(OBJECT_DIR)/libgtest.a $(OBJECT_DIR)/libArachne.a
106106
$(CXX) $(INCLUDE) $(CXXFLAGS) $< $(GTEST_DIR)/src/gtest_main.cc $(TEST_LIBS) $(LIBS) -o $@
107107

108108
$(OBJECT_DIR)/libgtest.a:

cwrapper/arachne_wrapper.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "Arachne.h"
2020
#include "CoreArbiter/CoreArbiterClient.h"
21-
#include "DefaultCoreManager.h"
21+
#include "DefaultCorePolicy.h"
2222
#include "arachne_wrapper.h"
2323

2424
#ifdef __cplusplus
@@ -70,7 +70,7 @@ arachne_wait_termination() {
7070

7171
/**
7272
* This function is the wrapper for Arachne::createThreadWithClass.
73-
* Under Arachne's default core manager, the following thread classes are
73+
* Under Arachne's default core policy, the following thread classes are
7474
* available.
7575
*
7676
* Class 0: Normal thread creation
@@ -146,7 +146,7 @@ arachne_thread_getid() {
146146
*/
147147
void
148148
arachne_set_maxutil(double maxutil) {
149-
reinterpret_cast<Arachne::DefaultCoreManager*>(Arachne::getCoreManager())
149+
reinterpret_cast<Arachne::DefaultCorePolicy*>(Arachne::getCorePolicy())
150150
->getEstimator()
151151
->setMaxUtilization(maxutil);
152152
}
@@ -157,8 +157,8 @@ arachne_set_maxutil(double maxutil) {
157157
*/
158158
void
159159
arachne_set_loadfactor(double loadfactor) {
160-
reinterpret_cast<Arachne::DefaultCoreManager*>(
161-
Arachne::getCoreManager())
160+
reinterpret_cast<Arachne::DefaultCorePolicy*>(
161+
Arachne::getCorePolicy())
162162
->getEstimator()
163163
->setLoadFactorThreshold(loadfactor);
164164
}

src/Arachne.cc

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include <stdio.h>
1717
#include <thread>
1818
#include "CoreArbiter/CoreArbiterClient.h"
19-
#include "CoreManager.h"
20-
#include "DefaultCoreManager.h"
19+
#include "CorePolicy.h"
20+
#include "DefaultCorePolicy.h"
2121
#include "PerfUtils/TimeTrace.h"
2222
#include "PerfUtils/Util.h"
2323

@@ -207,9 +207,9 @@ std::string coreArbiterSocketPath;
207207
CoreArbiterClient* coreArbiter = NULL;
208208

209209
/*
210-
* The CoreManager that Arachne will use.
210+
* The CorePolicy that Arachne will use.
211211
*/
212-
CoreManager* coreManager = NULL;
212+
CorePolicy* corePolicy = NULL;
213213

214214
// Forward declarations
215215
void releaseCore();
@@ -284,7 +284,7 @@ threadMain() {
284284
*core.localOccupiedAndCount = {0, 0};
285285
*publicPriorityMasks[core.kernelThreadId] = 0;
286286
core.privatePriorityMask = 0;
287-
coreManager->coreAvailable(core.kernelThreadId);
287+
corePolicy->coreAvailable(core.kernelThreadId);
288288

289289
// This marks the point at which new thread creations may begin.
290290
numActiveCores++;
@@ -805,8 +805,8 @@ waitForTermination() {
805805
publicPriorityMasks.clear();
806806
PerfUtils::Util::serialize();
807807
coreArbiter->reset();
808-
delete coreManager;
809-
coreManager = NULL;
808+
delete corePolicy;
809+
corePolicy = NULL;
810810
initialized = false;
811811
}
812812

@@ -957,30 +957,30 @@ ThreadContext::initializeStack() {
957957
* than the default. This function should be invoked before Arachne::init(),
958958
* and the object passed in is owned by Arachne after this function returns.
959959
*
960-
* \param arachneCoreManager
961-
* A pointer to the CoreManager that Arachne will use. The CoreManager
960+
* \param arachneCorePolicy
961+
* A pointer to the CorePolicy that Arachne will use. The CorePolicy
962962
* controls thread allocation to cores.
963963
*/
964964
void
965-
setCoreManager(CoreManager* arachneCoreManager) {
965+
setCorePolicy(CorePolicy* arachneCorePolicy) {
966966
if (initialized) {
967967
ARACHNE_LOG(ERROR,
968968
"Attempting to set core policy after Arachne::init has "
969969
"already been invoked");
970970
abort();
971971
}
972-
if (coreManager != NULL)
973-
delete coreManager;
974-
coreManager = arachneCoreManager;
972+
if (corePolicy != NULL)
973+
delete corePolicy;
974+
corePolicy = arachneCorePolicy;
975975
}
976976

977977
/**
978978
* Get the current core policy used by Arachne. This should be used only for
979979
* testing.
980980
*/
981-
CoreManager*
982-
getCoreManager() {
983-
return coreManager;
981+
CorePolicy*
982+
getCorePolicy() {
983+
return corePolicy;
984984
}
985985

986986
/**
@@ -1044,9 +1044,9 @@ init(int* argcp, const char** argv) {
10441044
maxNumCores, hardwareCoresAvailable);
10451045
}
10461046

1047-
if (coreManager == NULL) {
1048-
coreManager =
1049-
new DefaultCoreManager(maxNumCores, !disableLoadEstimation);
1047+
if (corePolicy == NULL) {
1048+
corePolicy =
1049+
new DefaultCorePolicy(maxNumCores, !disableLoadEstimation);
10501050
}
10511051

10521052
std::vector<uint32_t> coreRequest({minNumCores, 0, 0, 0, 0, 0, 0, 0});
@@ -1420,18 +1420,18 @@ descheduleCore() {
14201420
}
14211421
coreId = ownedCores.back();
14221422
ownedCores.pop_back();
1423-
coreManager->coreUnavailable(coreId);
1423+
corePolicy->coreUnavailable(coreId);
14241424
}
14251425
if (createThreadOnCore(coreId, releaseCore) == NullThread) {
1426-
coreManager->coreAvailable(coreId);
1426+
corePolicy->coreAvailable(coreId);
14271427
coreChangeActive = false;
14281428
ARACHNE_LOG(WARNING, "Release core thread creation failed to %d!\n",
14291429
coreId);
14301430
}
14311431
}
14321432

14331433
/**
1434-
* This function can be called from CoreManagers to increase the number of
1434+
* This function can be called from CorePolicys to increase the number of
14351435
* cores used by Arachne.
14361436
*/
14371437
void
@@ -1503,7 +1503,7 @@ checkForArbiterRequest() {
15031503
/**
15041504
* After this function returns, threads may no longer be added to the target
15051505
* core. This function can be invoked from any thread on any core. It is
1506-
* invoked by CoreManagers to block creations when cores transition
1506+
* invoked by CorePolicys to block creations when cores transition
15071507
* between thread classes.
15081508
*/
15091509
void
@@ -1576,8 +1576,8 @@ migrateThreadsFromCore() {
15761576
// Choose a victim core that we will pawn our work on.
15771577
if ((blockedOccupiedAndCount.occupied >> i) & 1) {
15781578
int threadClass = core.localThreadContexts[i]->threadClass;
1579-
CoreManager::CoreList outputCores =
1580-
coreManager->getCores(threadClass);
1579+
CorePolicy::CoreList outputCores =
1580+
corePolicy->getCores(threadClass);
15811581
if (outputCores.size() == 0) {
15821582
ARACHNE_LOG(ERROR, "No available cores to migrate threads to.");
15831583
exit(1);
@@ -1749,7 +1749,7 @@ prepareForExclusiveUse(int coreId) {
17491749
* CoreList and return its Id.
17501750
*/
17511751
int
1752-
findAndClaimUnusedCore(CoreManager::CoreList* cores) {
1752+
findAndClaimUnusedCore(CorePolicy::CoreList* cores) {
17531753
for (uint32_t i = 0; i < cores->size(); i++) {
17541754
int coreId = cores->get(i);
17551755
MaskAndCount slotMap = *occupiedAndCount[coreId];

src/Arachne.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <vector>
2929

3030
#include "Common.h"
31-
#include "CoreManager.h"
31+
#include "CorePolicy.h"
3232
#include "Logger.h"
3333
#include "PerfStats.h"
3434
#include "PerfUtils/Cycles.h"
@@ -72,7 +72,7 @@ extern std::function<void()> initCore;
7272

7373
extern std::vector<ThreadContext**> allThreadContexts;
7474

75-
extern CoreManager* coreManager;
75+
extern CorePolicy* corePolicy;
7676

7777
extern std::atomic<bool>* coreIdle;
7878

@@ -137,11 +137,11 @@ void idleCore(int coreId);
137137
void unidleCore(int coreId);
138138

139139
bool removeAllThreadsFromCore(int coreId,
140-
CoreManager::CoreManager::CoreList outputCores);
140+
CorePolicy::CorePolicy::CoreList outputCores);
141141
void makeSharedOnCore();
142142

143-
void setCoreManager(CoreManager* arachneCoreManager);
144-
CoreManager* getCoreManager();
143+
void setCorePolicy(CorePolicy* arachneCorePolicy);
144+
CorePolicy* getCorePolicy();
145145

146146
void block();
147147
void signal(ThreadId id);
@@ -312,7 +312,7 @@ struct ThreadContext {
312312

313313
/// Specified by applications to indicate general properties of this thread
314314
/// (e.g. latency-sensitive foreground thread vs throughput-sensitive
315-
/// background thread); used by CoreManager.
315+
/// background thread); used by CorePolicy.
316316
// It defaults to 0 for threads created without specifying a class.
317317
int threadClass = 0;
318318

@@ -451,7 +451,7 @@ random(void) {
451451
// in the CC file causes the compiler to generate an independent version of the
452452
// random() function above.
453453
static int
454-
chooseCore(const CoreManager::CoreList& coreList) {
454+
chooseCore(const CorePolicy::CoreList& coreList) {
455455
uint32_t index1 = static_cast<uint32_t>(random()) % coreList.size();
456456
uint32_t index2 = static_cast<uint32_t>(random()) % coreList.size();
457457
while (index2 == index1 && coreList.size() > 1)
@@ -554,7 +554,7 @@ createThreadOnCore(uint32_t coreId, _Callable&& __f, _Args&&... __args) {
554554
return ThreadId(threadContext, generation);
555555
}
556556

557-
int chooseCore(const CoreManager::CoreList& coreList);
557+
int chooseCore(const CorePolicy::CoreList& coreList);
558558

559559
////////////////////////////////////////////////////////////////////////////////
560560
// The ends the private section of the thread library.
@@ -565,7 +565,7 @@ int chooseCore(const CoreManager::CoreList& coreList);
565565
*
566566
* \param threadClass
567567
* The class of the thread being created; its meaning is determined by the
568-
* currently running CoreManager.
568+
* currently running CorePolicy.
569569
* \param __f
570570
* The main function for the new thread.
571571
* \param __args
@@ -584,7 +584,7 @@ ThreadId
584584
createThreadWithClass(int threadClass, _Callable&& __f, _Args&&... __args) {
585585
// Find a core to enqueue to by picking two at random and choosing
586586
// the one with the fewest Arachne threads.
587-
CoreManager::CoreList coreList = coreManager->getCores(threadClass);
587+
CorePolicy::CoreList coreList = corePolicy->getCores(threadClass);
588588
if (coreList.size() == 0)
589589
return Arachne::NullThread;
590590
uint32_t kId = static_cast<uint32_t>(chooseCore(coreList));

0 commit comments

Comments
 (0)