Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Prerequisites
*.d

# Object files
*.o
*.ko
*.obj
*.elf

# Linker output
*.ilk
*.map
*.exp

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/
*.su
*.idb
*.pdb

# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf

# debug information files
*.dwo

# LSP files
compile_flags.txt
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
.POSIX:
.SUFFIXES:

# Use the system's default C compiler
# was gnu89 reallyyyy necessary ....
# surely gradescope machines have a compiler which can do post Y2K C ....

CC = cc
CFLAGS = -Wall -Wpointer-arith -Wstrict-prototypes -std=c11 -fPIC

# Pathname of the pkg-config compatible utility
# (not using this for this assignment at all)
#PC = pkg-config

# Instructions to create an LSP db -- default is clangd with compile_flags.txt
# e.g. To use bear you can set DB="bear -- make" which will create compile_commands.json
DB = echo $(LDFLAGS) $(CFLAGS) | tr ' ' '\n' > compile_flags.txt

# Project Files
BIN=test-mergesort
OBJ=test-mergesort.o mergesort.o
SRC=$(OBJ:%.o=%.c)
DEP=$(OBJ:%.o=%.d)

all: $(BIN)

# Build binary from objects
$(BIN): $(OBJ)
$(CC) $(CFLAGS) -o $@ $(OBJ) $(LDFLAGS)

# Suffix rules to create .o and .d files from sources
.SUFFIXES: .c .o
.c.o:
$(CC) $(CFLAGS) $(INC) -c $<

.SUFFIXES: .c .d
.c.d:
$(CC) -MM $< -o $@

# Unit tests
test: mergesort.o merge_test.o buildargs_test.o
$(CC) $(CFLAGS) -o merge.test merge_test.o mergesort.o
$(CC) $(CFLAGS) -o buildargs.test buildargs_test.o mergesort.o

# Generate LSP database on each clean
db:
$(DB)

clean: db
rm -fr $(BIN)
rm -fr $(OBJ)
rm -fr $(DEP)

# For FreeBSD make use -include
-include $(DEP)
75 changes: 75 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
README.template

## Project Number/Title

* Authors: Izak Baldacchino (a1830164), Bunsarak Ann (a1827385), Matthew Edmonds-Wilson(a1850372)
* Group name: Assignment 3 Groups 190

## Overview

This program benchmarks the performance of the parallel merge sort algorithm.
Given an array of random integers of size N, and a "level", it performs merge
sort; each time the array is partitioned, a new thread is spawned to perform
the recursive merge sort on the sub-array. This continues until the "level"
is exceeded.

## Manifest

Makefile -- the recipes which are used to compile the project.
README.md -- this file!
mergesort.c -- contains the source for the functions which need to be implemented.
mergesort.h -- contains the declarations for the functions and structs used.
test-mergesort.c -- contains the source for the program which runs the algorithm.

## Building the project

To build the project simply execute `make`. This assumes it is being built on a UNIX-like
system which features some rendition of the `make` utility. In fact, any system which is
POSIX-compliant shall be able to execute and run this makefile.

From this point execute the built executable `./test-mergesort` and provide relevant arguments.

## Features and usage

To run the program use `./test-mergesort N level seed` where `N` refers to the size of the generated
array, `level` refers to the number of times the array is partitioned and sorted in parallel, and
`seed` is used as the seed for generating the random array; same seed = same array.

TODO: write more perhaps?

## Testing

This section should detail how you tested your code. Simply stating "I ran
it a few times and it seems to work" is not sufficient. Your testing needs
to be detailed here.


TODO: figure out testing scheme.

## Known Bugs

List known bugs that you weren't able to fix (or ran out of time to fix).

TODO: haven't made any bugs yet ...

## Reflection and Self Assessment

Discuss the issues you encountered during development and testing. What
problems did you have? What did you have to research and learn on your own?
What kinds of errors did you get? How did you fix them?

What parts of the project did you find challenging? Is there anything that
finally "clicked" for you in the process of working on this project? How well
did the development and testing process go for you?


TODO: haven't finished yet ...

## Sources Used

If you used any sources outside of the textbook, you should list them here.
If you looked something up on stackoverflow.com or you use help from AI, and
fail to cite it in this section, it will be considered plagiarism and dealt
with accordingly. So be safe CITE!

TODO: haven't used any sources yet ...
60 changes: 60 additions & 0 deletions buildargs_test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

#include "mergesort.h"

int* A;
int* B;

int cutoff;

int main(void) {

struct argument* p;

{
/* check that a valid struct is built */
printf("Test 1: a valid struct is built from valid arguments\n");
p = buildArgs(0,4,0);
assert(p->left == 0);
assert(p->right == 4);
assert(p->level == 0);
printf("Test 1: Passed\n");
}

{
printf("Test 2: NULL is returned for left > right\n");
p = buildArgs(6,5,5);
assert(p == NULL);
printf("Test 2: Passed\n");
}

{
printf("Test 3: NULL is returned for negative left\n");
p = buildArgs(-1,5,5);
assert(p == NULL);
printf("Test 3: Passed\n");
}

{
printf("Test 4: NULL is returned for negative right\n");
p = buildArgs(1,-5,5);
assert(p == NULL);
printf("Test 4: Passed\n");
}

{
printf("Test 5: NULL is returned for negative level\n");
p = buildArgs(1,5,-5);
assert(p == NULL);
printf("Test 5: Passed\n");
}

{
printf("Test 6: NULL is returned for all negative arguments\n");
p = buildArgs(-1,-5,-5);
assert(p == NULL);
printf("Test 6: Passed\n");
}
}
12 changes: 0 additions & 12 deletions comp2002-os-mergesort/Makefile

This file was deleted.

57 changes: 0 additions & 57 deletions comp2002-os-mergesort/README.template

This file was deleted.

27 changes: 0 additions & 27 deletions comp2002-os-mergesort/mergesort.c

This file was deleted.

Loading