diff options
-rw-r--r-- | csci5451/ass1.tex | 11 | ||||
-rw-r--r-- | csci5451/ass1p6.c | 30 |
2 files changed, 27 insertions, 14 deletions
diff --git a/csci5451/ass1.tex b/csci5451/ass1.tex index 6dbdfc1..24f2e0c 100644 --- a/csci5451/ass1.tex +++ b/csci5451/ass1.tex @@ -7,10 +7,13 @@ \begin{document} \maketitle \section{Question 1} - \subsection{Overlapping Intervals} - - \subsection{Non-Overlapping Intervals} - \(t_{transfer} = t_s+t_w*d*m/k*k\) or \(\sum_{i=1}^{k} t_s+t+w*d*m/k\) + \subsection*{Overlapping Intervals} + The time for one message to be sent 1 hop is \(t_s+t_w*m/k\). After the first message is sent forward one hop, we account for the final message \((d-1)*t_w*m/k\), making the final expression + \[k(t_s+t_w+m/k)+((d-1)t_w*m/k)\] + \subsection*{Non-Overlapping Intervals} + \[t_{transfer} = t_s*k+t_w*d*m\] + \subsection*{} + For both cases, as \(k\) goes to \(m\), the time to transfer will increase greatly. If \(t_s\) is very large, the optimal value of \(k\) is 1. In other words, it is better to transfer the message all at once instead of in \(k\) parts. If \(t_s\) is 0 it has little to no effect on overall transmission time regardless of \(k\) being large or small. \section{Question 2} \subsection*{A} Shared memory has all of the processors access one large pool of memory while distributed memory has each processor have a section of the memory. diff --git a/csci5451/ass1p6.c b/csci5451/ass1p6.c index 3b4a1bb..d87eddd 100644 --- a/csci5451/ass1p6.c +++ b/csci5451/ass1p6.c @@ -26,7 +26,8 @@ // is run for a fixed number of time steps rather than until // temperatures reach steady state. -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ int max_time = 50; // Number of time steps to simulate int width = 20; // Number of cells in the rod double initial_temp = 50.0; // Initial temp of internal cells @@ -38,25 +39,30 @@ int main(int argc, char **argv) { // Allocate memory H = malloc(sizeof(double *) * max_time); int t, p; - for (t = 0; t < max_time; t++) { + for (t = 0; t < max_time; t++) + { H[t] = malloc(sizeof(double *) * width); } // Initialize constant left/right boundary temperatures - for (t = 0; t < max_time; t++) { + for (t = 0; t < max_time; t++) + { H[t][0] = L_bound_temp; H[t][width - 1] = R_bound_temp; } // Initialize temperatures at time 0 t = 0; - for (p = 1; p < width - 1; p++) { + for (p = 1; p < width - 1; p++) + { H[t][p] = initial_temp; } // Simulate the temperature changes for internal cells - for (t = 0; t < max_time - 1; t++) { - for (p = 1; p < width - 1; p++) { + for (t = 0; t < max_time - 1; t++) + { + for (p = 1; p < width - 1; p++) + { double left_diff = H[t][p] - H[t][p - 1]; double right_diff = H[t][p] - H[t][p + 1]; double delta = -k * (left_diff + right_diff); @@ -71,19 +77,23 @@ int main(int argc, char **argv) { // Column headers printf("%3s| ", ""); - for (p = 0; p < width; p++) { + for (p = 0; p < width; p++) + { printf("%5d ", p); } printf("\n"); printf("%3s+-", "---"); - for (p = 0; p < width; p++) { + for (p = 0; p < width; p++) + { printf("------"); } printf("\n"); // Row headers and data - for (t = 0; t < max_time; t++) { + for (t = 0; t < max_time; t++) + { printf("%3d| ", t); - for (p = 0; p < width; p++) { + for (p = 0; p < width; p++) + { printf("%5.1f ", H[t][p]); } printf("\n"); |