From 3f87b640b3852e8815bb5ed57f71e0d71ff43262 Mon Sep 17 00:00:00 2001 From: RustyRaptor Date: Wed, 22 Sep 2021 15:47:03 -0600 Subject: [PATCH] deleted junk files --- Makefile | 8 ----- count3.c | 37 -------------------- testthread.c | 97 ---------------------------------------------------- 3 files changed, 142 deletions(-) delete mode 100644 Makefile delete mode 100644 count3.c delete mode 100644 testthread.c diff --git a/Makefile b/Makefile deleted file mode 100644 index dbfd072..0000000 --- a/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -all: testthread - -testthread: testthread.c - gcc -pthread -o testthread testthread.c - -clean: - rm -rf testthread - diff --git a/count3.c b/count3.c deleted file mode 100644 index a1baa7b..0000000 --- a/count3.c +++ /dev/null @@ -1,37 +0,0 @@ -/* -Ziad Arafat -08/26/2021 - -- Created file - -This file will fill an array with random numbers between 0 and 3 inclusive. -It will then use a serial function to count the number of 3s in the function. -After that we will begin to implement the parallel version. - - - -*/ - -#include -#include -#include - -struct rand_three { - int array[20]; -}; - -struct rand_three rand_arr(struct rand_three my_arr) { - struct rand_three x = my_arr; - for (int i = 0; i < 20; i++) { - rand_three->array[i] = 0; - } -} - -int main(int argc, char const *argv[]) { - srand(time(0)); - // Create an empty array - // set it equal to rand_arr(my_arr) - // set count to count_3_serial() - // print the result - return 0; -} diff --git a/testthread.c b/testthread.c deleted file mode 100644 index 6407349..0000000 --- a/testthread.c +++ /dev/null @@ -1,97 +0,0 @@ -// Ziad Arafat -// Aug 31 2021 -// Testing threads - -#include -#include -#include -#include - -int *A; -int COUNT = 0; -int SEGSIZE; -int NUMOFTHREADS; - -void count3s(int index) -{ - int mystart = index * SEGSIZE; - int myend = mystart + SEGSIZE; - - for (int i = mystart; i < myend; i++) { - if (A[i] == 3) { - COUNT++; - } - } -} - -void count3s_parallel() -{ - pthread_t my_t_connector; - for (int i = 0; i < NUMOFTHREADS; i++) { - count3s(i); - pthread_create(&my_t_connector, NULL, count3s, i); - } -} - -int main(int argc, char const *argv[]) -{ - int size; - - time_t t; - - srand((unsigned)time(&t)); - - // printf("argc is %d \n", argc); - // printf("name of program is %s \n", argv[0]); - // if (argc > 1) { - // printf("number is %s \n", argv[1]); - // } else { - // printf("We need an argument >:( \n"); - // exit(1); - // } - - if (argc != 3) { - printf("Not fcorrect arguments \n"); - printf("Usage %s \n", - argv[0]); - exit(1); - } - - size = atoi(argv[1]); - NUMOFTHREADS = atoi(argv[2]); - SEGSIZE = size / NUMOFTHREADS; - - // printf("number is %s \n", argv[1]); - // printf("number is %d \n", SIZE); - - A = (int *)(malloc(sizeof(int) * size)); - - if (A == NULL) { - printf("Austin, we have a problem"); - } - - for (int i = 0; i < size; i++) { - A[i] = rand() % 4; - // printf("%d \n", A[i]); - } - - // do the work parallel - - count3s_parallel(); - - for (int i = 0; i < NUMOFTHREADS; i++) { - count3s(i); - } - - // do the work serial - int local_count = 0; - for (int i = 0; i < size; i++) { - if (A[i] == 3) - local_count++; - } - - printf("parallel count is %d\n", COUNT); - printf("serial count is %d\n", local_count); - - return 0; -}