Homework 1
This homework has 3 problems. The goal of the first homework is to ensure that you can access the compute resources on campus, compile MPI programs, and write massively parallel programs
Collaboration
You may discuss all aspects of the program with your classmates. However, you should never show any of your code to another student, and you should never copy anyone else's code without an explicit acknowledgment.
0) Log in
For the first problem, ensure that you can log in to the Course Compute Infrastructure. Once you can login to all of the machines, login to the shared memory system and create a file containing:- Your Name
- Your Program & Year
- Why you are taking this course in exactly two sentences.
- One problem you wish to solve using MPI
- Send the content of this file to rhl@stanford.edu
- Put CME194: in the front of the subject line
1) Hello, World
- Write a hello world program in which each processor reports it's rank
- Write a MOAB submit script
- Submit this job to the cluster
2) Circuit Satisfiability
- Expand on hello world to solve circuit satisifiability.
- Use this code to check the circuit
/* Return 1 if 'i'th bit of 'n' is 1; 0 otherwise */
void check_circuit (int id, int z) {
int v[16]; /* Each element is a bit of z */
int i;
for (i = 0; i < 16; i++){ v[i] = ((z&(1<<i))?1:0); }
if ((v[0] || v[1]) && (!v[1] || !v[3]) && (v[2] || v[3])
&& (!v[3] || !v[4]) && (v[4] || !v[5])
&& (v[5] || !v[6]) && (v[5] || v[6])
&& (v[6] || !v[15]) && (v[7] || !v[8])
&& (!v[7] || !v[13]) && (v[8] || v[9])
&& (v[8] || !v[9]) && (!v[9] || !v[10])
&& (v[9] || v[11]) && (v[10] || v[11])
&& (v[12] || v[13]) && (v[13] || !v[14])
&& (v[14] || v[15])) {
printf ("%d) %d%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d\n", id,
v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9],
v[10],v[11],v[12],v[13],v[14],v[15]);
fflush (stdout);
}
}