first commit
This commit is contained in:
BIN
example/a.out
Executable file
BIN
example/a.out
Executable file
Binary file not shown.
70
example/cubeICN.cpp
Normal file
70
example/cubeICN.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <mpi.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//#include "/usr/local/include/mpi.h"
|
||||
#define MCW MPI_COMM_WORLD
|
||||
|
||||
using namespace std;
|
||||
|
||||
void allPrint(int data){
|
||||
int array[64];
|
||||
int rank, size;
|
||||
|
||||
MPI_Comm_rank(MCW, &rank);
|
||||
MPI_Comm_size(MCW, &size);
|
||||
|
||||
MPI_Gather(&data,1,MPI_INT,array,1,MPI_INT,0,MCW);
|
||||
if(!rank){
|
||||
for(int i=0;i<size;++i)cout<<i<<" ";
|
||||
cout<<endl;
|
||||
for(int i=0;i<size;++i)cout<<array[i]<<" ";
|
||||
cout<<endl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void cube(int f, int *data){
|
||||
int rank, size;
|
||||
int dest;
|
||||
int mask=1;
|
||||
mask <<= f;
|
||||
|
||||
MPI_Comm_rank(MCW, &rank);
|
||||
MPI_Comm_size(MCW, &size);
|
||||
|
||||
dest = rank ^ mask;
|
||||
|
||||
MPI_Send(data,1,MPI_INT,dest,0,MCW);
|
||||
MPI_Recv(data,1,MPI_INT,MPI_ANY_SOURCE,0,MCW,MPI_STATUS_IGNORE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
|
||||
int rank, size;
|
||||
int data;
|
||||
MPI_Init(&argc, &argv);
|
||||
MPI_Comm_rank(MCW, &rank);
|
||||
MPI_Comm_size(MCW, &size);
|
||||
|
||||
data = rank;
|
||||
|
||||
allPrint(data);
|
||||
cube(2,&data);
|
||||
cout<<endl;
|
||||
allPrint(data);
|
||||
|
||||
|
||||
|
||||
MPI_Finalize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
5
example/pachinco/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
example/pachinco/.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
|
||||
</state>
|
||||
</component>
|
||||
6
example/pachinco/.idea/misc.xml
generated
Normal file
6
example/pachinco/.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptSettings">
|
||||
<option name="languageLevel" value="ES6" />
|
||||
</component>
|
||||
</project>
|
||||
8
example/pachinco/.idea/modules.xml
generated
Normal file
8
example/pachinco/.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/pachinco.iml" filepath="$PROJECT_DIR$/.idea/pachinco.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
8
example/pachinco/.idea/pachinco.iml
generated
Normal file
8
example/pachinco/.idea/pachinco.iml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="CPP_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
68
example/pachinco/.idea/workspace.xml
generated
Normal file
68
example/pachinco/.idea/workspace.xml
generated
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeRunConfigurationManager" shouldGenerate="true" shouldDeleteObsolete="true">
|
||||
<generated />
|
||||
</component>
|
||||
<component name="CMakeSettings">
|
||||
<configurations>
|
||||
<configuration PROFILE_NAME="Debug" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="1ec8baf7-c36e-415f-96a3-9219f74f3144" name="Default Changelist" comment="" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="MacroExpansionManager">
|
||||
<option name="directoryName" value="nlumVDio" />
|
||||
</component>
|
||||
<component name="ProjectId" id="1WPqoAEvmJQAG3ylPB23Icr232G" />
|
||||
<component name="PropertiesComponent">
|
||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||
<property name="cf.advertisement.text.overridden" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||
<property name="node.js.detected.package.eslint" value="true" />
|
||||
<property name="node.js.detected.package.tslint" value="true" />
|
||||
<property name="node.js.path.for.package.eslint" value="project" />
|
||||
<property name="node.js.path.for.package.tslint" value="project" />
|
||||
<property name="node.js.selected.package.eslint" value="(autodetect)" />
|
||||
<property name="node.js.selected.package.tslint" value="(autodetect)" />
|
||||
<property name="nodejs_package_manager_path" value="npm" />
|
||||
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
<option name="ruleStates">
|
||||
<list>
|
||||
<RuleState>
|
||||
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
<RuleState>
|
||||
<option name="name" value="StatusDashboardGroupingRule" />
|
||||
</RuleState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
</component>
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="1ec8baf7-c36e-415f-96a3-9219f74f3144" name="Default Changelist" comment="" />
|
||||
<created>1579061749869</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1579061749869</updated>
|
||||
<workItem from="1579061753840" duration="812000" />
|
||||
<workItem from="1579236356017" duration="351000" />
|
||||
<workItem from="1579842846262" duration="3379000" />
|
||||
<workItem from="1581113414207" duration="10085000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="1" />
|
||||
</component>
|
||||
</project>
|
||||
BIN
example/pachinco/a.out
Executable file
BIN
example/pachinco/a.out
Executable file
Binary file not shown.
55
example/pachinco/pachinko.cpp
Normal file
55
example/pachinco/pachinko.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <mpi.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <time>
|
||||
|
||||
//#include "/usr/local/include/mpi.h"
|
||||
#define MCW MPI_COMM_WORLD
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int rank, size;
|
||||
int data;
|
||||
int dest;
|
||||
MPI_Init(&argc, &argv);
|
||||
MPI_Comm_rank(MCW, &rank);
|
||||
MPI_Comm_size(MCW, &size);
|
||||
srand(rank);
|
||||
|
||||
if (rank == 0) {
|
||||
data = rand % 20;
|
||||
cout << "Timer is set to " << data << endl;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
MPI_Recv(&data, 1, MPI_INT, MPI_ANY_SOURCE, 0, MCW, MPI_STATUS_IGNORE);
|
||||
dest = rank++;
|
||||
|
||||
if (!(rand() % 5)) {
|
||||
data = -1;
|
||||
for (int i = 0; i < size; ++i)
|
||||
MPI_Send(&data, 1, MPI_INT, i, 0, MCW);
|
||||
}
|
||||
|
||||
if (data != 0) {
|
||||
data--;
|
||||
} else {
|
||||
dest = rank - 1;
|
||||
if (dest < 0)
|
||||
dest = size - 1;
|
||||
}
|
||||
|
||||
MPI_Send(&data, 1, MPI_INT, dest, 0, MCW);
|
||||
|
||||
cout << "rank " << rank << " is done.\n";
|
||||
|
||||
MPI_Finalize();
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
33
example/parallelRoundRobin.cpp
Normal file
33
example/parallelRoundRobin.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
#include <mpi.h>
|
||||
|
||||
#define MCW MPI_COMM_WORLD
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int rank;
|
||||
int size;
|
||||
int data;
|
||||
|
||||
MPI_Init(&argc, &argv);
|
||||
|
||||
//returns my rank in the MCW.
|
||||
MPI_Comm_rank(MCW, &rank);
|
||||
//how many things there are in this communicator.
|
||||
MPI_Comm_size(MCW, &size);
|
||||
if(rank == 0){
|
||||
data = rand()%100;
|
||||
cout << "Process " << rank << "gerated " << data << "\n";
|
||||
|
||||
MPI_Send(&rank, 1, MPI_INT, (rank+1)%size, 0, MCW);
|
||||
|
||||
MPI_Recv(&data, 1, MPI_INT, MPI_ANY_SOURCE, 0, MCW, MPI_STATUS_IGNORE);
|
||||
}
|
||||
|
||||
|
||||
MPI_Recv(&data, 1, MPI_INT, MPI_ANY_SOURCE, 0, MCW, MPI_STATUS_IGNORE);
|
||||
cout << "I am " << rank << " of " << size << "; got a message from " << data <<endl;
|
||||
|
||||
MPI_Finalize();
|
||||
return 0;
|
||||
}
|
||||
42
example/parallellHello.cpp
Normal file
42
example/parallellHello.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <iostream>
|
||||
#include <mpi.h>
|
||||
|
||||
#define MCW MPI_COMM_WORLD
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int rank;
|
||||
int size;
|
||||
int data;
|
||||
|
||||
MPI_Init(&argc, &argv);
|
||||
|
||||
//returns my rank in the MCW.
|
||||
MPI_Comm_rank(MCW, &rank);
|
||||
//how many things there are in this communicator.
|
||||
MPI_Comm_size(MCW, &size);
|
||||
|
||||
//Sends info
|
||||
//&rank- location of send buffer.
|
||||
//1- how many things in the buffer.
|
||||
//MPI_INT- tells what type to turn the data into..
|
||||
//(rank+1)%size- return number.
|
||||
//0- tag
|
||||
//MCW- communicator and other things.
|
||||
MPI_Send(&rank, 1, MPI_INT, (rank+1)%size, 0, MCW);
|
||||
|
||||
//Recieves information
|
||||
//&data where to put the return data.
|
||||
//1- how many.
|
||||
//MPI_INT- type.
|
||||
//MPI_ANY_SOURCE- can come from any process.
|
||||
//0- tag.
|
||||
//mcw- communicator type
|
||||
//MPI_STATUS_IGNORE-
|
||||
MPI_Recv(&data, 1, MPI_INT, MPI_ANY_SOURCE, 0, MCW, MPI_STATUS_IGNORE);
|
||||
|
||||
cout << "I am " << rank << " of " << size << "; got a message from " << data <<endl;
|
||||
|
||||
MPI_Finalize();
|
||||
return 0;
|
||||
}
|
||||
9
example/serialHello.cpp
Normal file
9
example/serialHello.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char ** argv){
|
||||
cout << "hello World/n";
|
||||
return 0;
|
||||
}
|
||||
10
example/test.cpp
Normal file
10
example/test.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char ** argv){
|
||||
cout << "hello World/n";
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user