From 483fa8458d834cd9ec3815a91e7ff712659dbe1b Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sun, 24 Apr 2016 20:12:20 -0400 Subject: [PATCH] delete trailing newlines --- Makefile | 8 ++++---- README | 4 ++-- cachelab.h | 6 +++--- test-trans.c | 34 +++++++++++++++++----------------- tracegen.c | 16 +++++++--------- trans.c | 25 ++++++++++++------------- 6 files changed, 45 insertions(+), 48 deletions(-) diff --git a/Makefile b/Makefile index 3e6c2e2..c18db0f 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,18 @@ # # Student makefile for Cache Lab -# +# CC = gcc CFLAGS = -g -Wall -Werror -std=c99 all: csim test-trans tracegen # Generate a handin tar file each time you compile - -tar -cvf ${USER}-handin.tar csim.c trans.c + -tar -cvf ${USER}-handin.tar csim.c trans.c csim: csim.c cachelab.c cachelab.h - $(CC) $(CFLAGS) -o csim csim.c cachelab.c -lm + $(CC) $(CFLAGS) -o csim csim.c cachelab.c -lm test-trans: test-trans.c trans.o cachelab.c cachelab.h - $(CC) $(CFLAGS) -o test-trans test-trans.c cachelab.c trans.o + $(CC) $(CFLAGS) -o test-trans test-trans.c cachelab.c trans.o tracegen: tracegen.c trans.o cachelab.c $(CC) $(CFLAGS) -O0 -o tracegen tracegen.c trans.o cachelab.c diff --git a/README b/README index e147bb4..e124452 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -This is the handout directory for the CS:APP Cache Lab. +This is the handout directory for the CS:APP Cache Lab. ************************ Running the autograders: @@ -16,7 +16,7 @@ Check the correctness and performance of your transpose functions: linux> ./test-trans -M 61 -N 67 Check everything at once (this is the program that your instructorruns): - linux> ./driver.py + linux> ./driver.py ****** Files: diff --git a/cachelab.h b/cachelab.h index 02f7730..9a19902 100644 --- a/cachelab.h +++ b/cachelab.h @@ -1,4 +1,4 @@ -/* +/* * cachelab.h - Prototypes for Cache Lab helper functions */ @@ -16,10 +16,10 @@ typedef struct trans_func{ unsigned int num_evictions; } trans_func_t; -/* +/* * printSummary - This function provides a standard way for your cache * simulator * to display its final hit and miss statistics - */ + */ void printSummary(int hits, /* number of hits */ int misses, /* number of misses */ int evictions); /* number of evictions */ diff --git a/test-trans.c b/test-trans.c index a5adfce..a77ec45 100644 --- a/test-trans.c +++ b/test-trans.c @@ -27,7 +27,7 @@ extern void registerFunctions(); /* External variables defined in cachelab-tools.c */ extern trans_func_t func_list[MAX_TRANS_FUNCS]; -extern int func_counter; +extern int func_counter; /* Globals set on the command line */ static int M = 0; @@ -41,7 +41,7 @@ struct results { }; static struct results results = {-1, 0, INT_MAX}; -/* +/* * eval_perf - Evaluate the performance of the registered transpose functions */ void eval_perf(unsigned int s, unsigned int E, unsigned int b) @@ -52,11 +52,11 @@ void eval_perf(unsigned int s, unsigned int E, unsigned int b) char buf[1000], cmd[255]; char filename[128]; - registerFunctions(); + registerFunctions(); /* Open the complete trace file */ - FILE* full_trace_fp; - FILE* part_trace_fp; + FILE* full_trace_fp; + FILE* part_trace_fp; /* Evaluate the performance of each registered transpose function */ @@ -71,7 +71,7 @@ void eval_perf(unsigned int s, unsigned int E, unsigned int b) sprintf(cmd, "valgrind --tool=lackey --trace-mem=yes --log-fd=1 -v ./tracegen -M %d -N %d -F %d > trace.tmp", M, N,i); flag=WEXITSTATUS(system(cmd)); if (0!=flag) { - printf("Validation error at function %d! Run ./tracegen -M %d -N %d -F %d for details.\nSkipping performance evaluation for this function.\n",flag-1,M,N,i); + printf("Validation error at function %d! Run ./tracegen -M %d -N %d -F %d for details.\nSkipping performance evaluation for this function.\n",flag-1,M,N,i); continue; } @@ -97,7 +97,7 @@ void eval_perf(unsigned int s, unsigned int E, unsigned int b) sprintf(filename, "trace.f%d", i); part_trace_fp = fopen(filename, "w"); assert(part_trace_fp); - + /* Locate trace corresponding to the trans function */ flag = 0; while (fgets(buf, 1000, full_trace_fp) != NULL) { @@ -106,7 +106,7 @@ void eval_perf(unsigned int s, unsigned int E, unsigned int b) if (buf[0]==' ' && buf[2]==' ' && (buf[1]=='S' || buf[1]=='M' || buf[1]=='L' )) { sscanf(buf+3, "%llx,%u", &addr, &len); - + /* If start marker found, set flag */ if (addr == marker_start) flag = 1; @@ -137,10 +137,10 @@ void eval_perf(unsigned int s, unsigned int E, unsigned int b) /* Run the reference simulator */ printf("Step 2: Evaluating performance (s=%d, E=%d, b=%d)\n", s, E, b); char cmd[255]; - sprintf(cmd, "./csim-ref -s %u -E %u -b %u -t trace.f%d > /dev/null", + sprintf(cmd, "./csim-ref -s %u -E %u -b %u -t trace.f%d > /dev/null", s, E, b, i); system(cmd); - + /* Collect results from the reference simulator */ FILE* in_fp = fopen(".csim_results","r"); assert(in_fp); @@ -151,13 +151,13 @@ void eval_perf(unsigned int s, unsigned int E, unsigned int b) func_list[i].num_evictions = evictions; printf("func %u (%s): hits:%u, misses:%u, evictions:%u\n", i, func_list[i].description, hits, misses, evictions); - + /* If it is transpose_submit(), record number of misses */ if (results.funcid == i) { results.misses = misses; } } - + } /* @@ -169,7 +169,7 @@ void usage(char *argv[]){ printf(" -h Print this help message.\n"); printf(" -M Number of matrix rows (max %d)\n", MAXN); printf(" -N Number of matrix columns (max %d)\n", MAXN); - printf("Example: %s -M 8 -N 8\n", argv[0]); + printf("Example: %s -M 8 -N 8\n", argv[0]); } /* @@ -192,7 +192,7 @@ void sigalrm_handler(int signum){ exit(1); } -/* +/* * main - Main routine */ int main(int argc, char* argv[]) @@ -215,7 +215,7 @@ int main(int argc, char* argv[]) exit(1); } } - + if (M == 0 || N == 0) { printf("Error: Missing required argument\n"); usage(argv); @@ -244,11 +244,11 @@ int main(int argc, char* argv[]) /* Check the performance of the student's transpose function */ eval_perf(5, 1, 5); - + /* Emit the results for this particular test */ if (results.funcid == -1) { printf("\nError: We could not find your transpose_submit() function\n"); - printf("Error: Please ensure that description field is exactly \"%s\"\n", + printf("Error: Please ensure that description field is exactly \"%s\"\n", SUBMIT_DESCRIPTION); printf("\nTEST_TRANS_RESULTS=0:0\n"); } diff --git a/tracegen.c b/tracegen.c index 33d3d21..0fd5763 100644 --- a/tracegen.c +++ b/tracegen.c @@ -1,7 +1,7 @@ -/* +/* * tracegen.c - Running the binary tracegen with valgrind produces - * a memory trace of all of the registered transpose functions. - * + * a memory trace of all of the registered transpose functions. + * * The beginning and end of each registered transpose function's trace * is indicated by reading from "marker" addresses. These two marker * addresses are recorded in file for later use. @@ -17,7 +17,7 @@ /* External variables declared in cachelab.c */ extern trans_func_t func_list[MAX_TRANS_FUNCS]; -extern int func_counter; +extern int func_counter; /* External function from trans.c */ extern void registerFunctions(); @@ -68,18 +68,18 @@ int main(int argc, char* argv[]){ exit(1); } } - + /* Register transpose functions */ registerFunctions(); /* Fill A with data */ - initMatrix(M,N, A, B); + initMatrix(M,N, A, B); /* Record marker addresses */ FILE* marker_fp = fopen(".marker","w"); assert(marker_fp); - fprintf(marker_fp, "%llx %llx", + fprintf(marker_fp, "%llx %llx", (unsigned long long int) &MARKER_START, (unsigned long long int) &MARKER_END ); fclose(marker_fp); @@ -103,5 +103,3 @@ int main(int argc, char* argv[]){ } return 0; } - - diff --git a/trans.c b/trans.c index e40f6fc..e6ec5db 100644 --- a/trans.c +++ b/trans.c @@ -1,4 +1,4 @@ -/* +/* * trans.c - Matrix transpose B = A^T * * Each transpose function must have a prototype of the form: @@ -6,30 +6,30 @@ * * A transpose function is evaluated by counting the number of misses * on a 1KB direct mapped cache with a block size of 32 bytes. - */ + */ #include #include "cachelab.h" int is_transpose(int M, int N, int A[N][M], int B[M][N]); -/* +/* * transpose_submit - This is the solution transpose function that you * will be graded on for Part B of the assignment. Do not change * the description string "Transpose submission", as the driver * searches for that string to identify the transpose function to - * be graded. + * be graded. */ char transpose_submit_desc[] = "Transpose submission"; void transpose_submit(int M, int N, int A[N][M], int B[M][N]) { } -/* +/* * You can define additional transpose functions below. We've defined - * a simple one below to help you get started. - */ + * a simple one below to help you get started. + */ -/* +/* * trans - A simple baseline transpose function, not optimized for the cache. */ char trans_desc[] = "Simple row-wise scan transpose"; @@ -42,7 +42,7 @@ void trans(int M, int N, int A[N][M], int B[M][N]) tmp = A[i][j]; B[j][i] = tmp; } - } + } } @@ -56,14 +56,14 @@ void trans(int M, int N, int A[N][M], int B[M][N]) void registerFunctions() { /* Register your solution function */ - registerTransFunction(transpose_submit, transpose_submit_desc); + registerTransFunction(transpose_submit, transpose_submit_desc); /* Register any additional transpose functions */ - registerTransFunction(trans, trans_desc); + registerTransFunction(trans, trans_desc); } -/* +/* * is_transpose - This helper function checks if B is the transpose of * A. You can check the correctness of your transpose by calling * it before returning from the transpose function. @@ -81,4 +81,3 @@ int is_transpose(int M, int N, int A[N][M], int B[M][N]) } return 1; } -