This commit is contained in:
Brady
2020-03-16 22:37:15 -06:00
parent 881a016341
commit 6474ac5d21
2 changed files with 48 additions and 42 deletions

View File

@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="AnalysisUIOptions">
<option name="SCOPE_TYPE" value="3" />
</component>
<component name="BuildServerSettings"> <component name="BuildServerSettings">
<option name="LOGIN" value="" /> <option name="LOGIN" value="" />
<option name="SERVER_URL" value="http://buildserver" /> <option name="SERVER_URL" value="http://buildserver" />
@@ -37,8 +40,6 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="2c8533ba-540f-4e3f-9945-3ca06f59f247" name="Default Changelist" comment=""> <list default="true" id="2c8533ba-540f-4e3f-9945-3ca06f59f247" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/CMakeFiles/main.dir/depend.make" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/CMakeFiles/main.dir/depend.make" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cmake-build-debug/main" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/main" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/main.cpp" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/main.cpp" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@@ -71,7 +72,7 @@
<property name="node.js.selected.package.eslint" value="(autodetect)" /> <property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" /> <property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="run.code.analysis.last.selected.profile" value="pProject Default" /> <property name="run.code.analysis.last.selected.profile" value="pProject Default" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" /> <property name="settings.editor.selected.configurable" value="inlay.hints.ObjectiveC" />
</component> </component>
<component name="RunManager"> <component name="RunManager">
<configuration name="main" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="HW7" TARGET_NAME="main" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="HW7" RUN_TARGET_NAME="main"> <configuration name="main" type="CMakeRunConfiguration" factoryName="Application" PASS_PARENT_ENVS_2="true" PROJECT_NAME="HW7" TARGET_NAME="main" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="HW7" RUN_TARGET_NAME="main">
@@ -93,6 +94,7 @@
<workItem from="1584397996277" duration="646000" /> <workItem from="1584397996277" duration="646000" />
<workItem from="1584399419332" duration="1165000" /> <workItem from="1584399419332" duration="1165000" />
<workItem from="1584410030817" duration="3105000" /> <workItem from="1584410030817" duration="3105000" />
<workItem from="1584418360198" duration="1236000" />
</task> </task>
<servers /> <servers />
</component> </component>
@@ -104,10 +106,10 @@
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state x="648" y="275" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog/0.0.1920.1080/-1920.135.1920.1080/1920.97.1920.1080@0.0.1920.1080" timestamp="1584399404367" /> <state x="648" y="275" key="#com.intellij.openapi.updateSettings.impl.PluginUpdateInfoDialog/0.0.1920.1080/-1920.135.1920.1080/1920.97.1920.1080@0.0.1920.1080" timestamp="1584399404367" />
<state x="712" y="403" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1" timestamp="1584418407417"> <state x="712" y="403" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1" timestamp="1584419433375">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state x="712" y="403" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1/0.0.1920.1080/-1920.135.1920.1080/1920.97.1920.1080@0.0.1920.1080" timestamp="1584418407417" /> <state x="712" y="403" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1/0.0.1920.1080/-1920.135.1920.1080/1920.97.1920.1080@0.0.1920.1080" timestamp="1584419433375" />
<state width="1878" height="357" key="GridCell.Tab.0.bottom" timestamp="1584417673541"> <state width="1878" height="357" key="GridCell.Tab.0.bottom" timestamp="1584417673541">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
@@ -144,10 +146,10 @@
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state width="1878" height="357" key="GridCell.Tab.1.right/0.0.1920.1080/-1920.135.1920.1080/1920.97.1920.1080@0.0.1920.1080" timestamp="1584417673543" /> <state width="1878" height="357" key="GridCell.Tab.1.right/0.0.1920.1080/-1920.135.1920.1080/1920.97.1920.1080@0.0.1920.1080" timestamp="1584417673543" />
<state x="469" y="179" key="SettingsEditor" timestamp="1584418565619"> <state x="469" y="179" key="SettingsEditor" timestamp="1584419373854">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />
</state> </state>
<state x="469" y="179" key="SettingsEditor/0.0.1920.1080/-1920.135.1920.1080/1920.97.1920.1080@0.0.1920.1080" timestamp="1584418565619" /> <state x="469" y="179" key="SettingsEditor/0.0.1920.1080/-1920.135.1920.1080/1920.97.1920.1080@0.0.1920.1080" timestamp="1584419373854" />
<state x="469" y="179" key="SettingsEditor/0.0.1920.1080/-1920.158.1920.1057/1920.120.1920.1057@0.0.1920.1080" timestamp="1584418349102" /> <state x="469" y="179" key="SettingsEditor/0.0.1920.1080/-1920.158.1920.1057/1920.120.1920.1057@0.0.1920.1080" timestamp="1584418349102" />
<state x="653" y="368" key="com.intellij.ide.util.TipDialog" timestamp="1584418360381"> <state x="653" y="368" key="com.intellij.ide.util.TipDialog" timestamp="1584418360381">
<screen x="0" y="0" width="1920" height="1080" /> <screen x="0" y="0" width="1920" height="1080" />

View File

@@ -3,6 +3,7 @@
#include<stdlib.h> #include<stdlib.h>
#include<time.h> #include<time.h>
#include<queue> #include<queue>
#define MCW MPI_COMM_WORLD #define MCW MPI_COMM_WORLD
#define GENERIC 0 #define GENERIC 0
#define SPECIAL 1 #define SPECIAL 1
@@ -87,17 +88,20 @@ int main(int argc, char **argv) {
MPI_Send(&tokenValue, 1, MPI_INT, dest, TOKEN, MCW); MPI_Send(&tokenValue, 1, MPI_INT, dest, TOKEN, MCW);
hasToken = false; hasToken = false;
myToken = SPECIAL; myToken = SPECIAL;
} } else {
else { int src = 0;
int src = rank - 1 >= 0 ? rank - 1 : size - 1; if(rank - 1 >= 0)
src = rank - 1;
else
src = size - 1;
MPI_Iprobe(src, TOKEN, MCW, &tokenFlag, &status); MPI_Iprobe(src, TOKEN, MCW, &tokenFlag, &status);
if (tokenFlag) { if (tokenFlag) {
MPI_Irecv(&tokenValue, 1, MPI_INT, src, TOKEN, MCW, &request); MPI_Irecv(&tokenValue, 1, MPI_INT, src, TOKEN, MCW, &request);
hasToken = true; hasToken = true;
if (rank == 0 && tokenValue == SPECIAL) { if (rank == 0 && tokenValue == SPECIAL) {
int globalStop = -1; int Stop = -1;
for (int i = 1; i < size; i++) { for (int i = 1; i < size; i++) {
MPI_Send(&globalStop, 1, MPI_INT, i, JOB, MCW); MPI_Send(&Stop, 1, MPI_INT, i, JOB, MCW);
} }
break; break;
} }