Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahpannn committed Jul 13, 2024
2 parents 9eff6b7 + 0c76223 commit cb95189
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 500 deletions.
86 changes: 0 additions & 86 deletions DEVELOPERS.md

This file was deleted.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
NUM_JOBS=$(shell nproc)
CXX=clang++

.PHONY: default examples/hello_world/build/hello_world tests libgpu debug build check-entr check-clang clean-build clean all watch-tests
.PHONY: default examples/hello_world/build/hello_world tests libgpu debug build check-entr check-clang clean-build clean all watch-tests docs

GPUCPP ?= $(PWD)
LIBDIR ?= $(GPUCPP)/third_party/lib
Expand All @@ -24,6 +24,9 @@ all: dawnlib check-clang check-linux-vulkan
cd examples/physics && make build/physics
cd examples/render && make build/render

docs: Doxyfile
doxygen Doxyfile

################################################################################
# cmake targets (optional - precompiled binaries is preferred)
################################################################################
Expand Down
209 changes: 129 additions & 80 deletions README.md

Large diffs are not rendered by default.

Binary file added docs/images/matmul.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/pendulum.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/shadertui.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion examples/hello_world/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,26 @@ NUM_JOBS?=$(shell nproc)
FLAGS=-stdlib=libc++ -std=c++17 -I$(GPUCPP) -I$(GPUCPP)/third_party/headers -L$(GPUCPP)/third_party/lib run.cpp -ldl -ldawn
TARGET=hello_world

run: ./build/$(TARGET)
run: ./build/$(TARGET) dawnlib
$(LIBSPEC) && ./build/$(TARGET)

dawnlib: $(if $(wildcard $(GPUCPP)/third_party/lib/libdawn.so $(GPUCPP)/third_party/lib/libdawn.dylib),,run_setup)

run_setup: check-python
cd $(GPUCPP) && python3 setup.py

all: dawnlib check-clang check-linux-vulkan
cd examples/gpu_puzzles && make build/gpu_puzzles
cd examples/hello_world && make build/hello_world
cd examples/matmul && make build/mm
cd examples/physics && make build/physics
cd examples/render && make build/render

build/$(TARGET): run.cpp
mkdir -p build && $(CXX) $(FLAGS) -DNDEBUG -o ./build/$(TARGET)

clean:
read -r -p "This will delete the contents of build/*. Are you sure? [CTRL-C to abort] " response && rm -rf build/*

check-python:
@command -v python3 >/dev/null 2>&1 || { echo >&2 "Python needs to be installed and in your path."; exit 1; }
2 changes: 1 addition & 1 deletion examples/hello_world/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int main(int argc, char **argv) {
dispatchKernel(ctx, op, promise);
wait(ctx, future);
toCPU(ctx, output, outputArr.data(), sizeof(outputArr));
for (int i = 0; i < 16; ++i) {
for (int i = 0; i < 12; ++i) {
printf(" gelu(%.2f) = %.2f\n", inputArr[i], outputArr[i]);
}
printf(" ...\n\n");
Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import platform
import sys
import ssl
import urllib.request
from pathlib import Path

Expand Down Expand Up @@ -28,13 +29,14 @@ def report_progress(block_num, block_size, total_size):
print(f"\rDownloaded {total_downloaded // (1024 * 1024)} MB", end="")

try:
ssl._create_default_https_context = ssl._create_stdlib_context
urllib.request.urlretrieve(url, output_filename, reporthook=report_progress)
print(f"\nDownloaded {output_filename}")
return True
except Exception as e:
print(f"\nFailed to download {output_filename}")
print(f"Error: {str(e)}")
return False
sys.exit(1)

def check_os(os_name):
print("\nChecking System")
Expand Down Expand Up @@ -63,15 +65,15 @@ def download_dawn(os_name):

if not outfile or not url:
print(f"No download information for {os_name}")
return
sys.exit(1)

print(f" URL : {url}")
print(f" Download File : {outfile}\n")
print(" Downloading ...\n")

if Path(outfile).exists():
print(f" File {outfile} already exists, skipping.")
return
sys.exit(0)

Path(outfile).parent.mkdir(parents=True, exist_ok=True)
download_file(url, outfile)
Expand Down
Loading

0 comments on commit cb95189

Please sign in to comment.