<commit_before># Basic operation

This is a simple 3d rendering engine.  There are currently a few hard-coded objects (torus, cube, and teapot) 
which can be selected by changing #defines at the top of main.cpp.

Rendering proceeds in two phases.  At the end of each phase, threads will block at a barrier until all 
other threads are finished.
- Geometry: the vertex shader is run on sets of vertex attributes.  It produces an array 
of vertex parameters.  Vertices are divided between threads, each of which processes 16 at a time (one
vertex per vector lane). There are up to 64 vertices in progress simultaneously per core (16 vertices
times four threads).
- Pixel: Triangles are rasterized and the vertex parameters are interpolated across
them.  The interpolated parameters are fed to the pixel shader, which returns color
values.  These values are blended and written back to the frame buffer.  Each thread
works on a single 64x64 tile of the screen at a time to ensure it is cache resident.
The rasterizer recursively subdivides triangles down to 4x4 squares (16 pixels). Each pixel
corresponds to a vector lane.  Similar to the geometry phase, 64 pixels are being processed
simultaneously.

The frame buffer is hard coded at location 0x100000 (1MB).

# How to run

- Install prerequisites mentioned in README at top level of project.

## Using instruction accurate simulator

This is the easiest way to run the engine and has the fewest external tool dependencies. It also executes fastest. From within this folder, type 'make run' to build and execute the project.  It will write the final contents of the framebuffer in fb.bmp.

It is also possible to see the output from the program in realtime in a Window if running on a Mac.  Once everything is built, run the following command:
<pre>
../../tools/simulator/simulator -m gui -w 512 -h 512 WORK/program.hex
</pre>

## Using Verilog model

Type 'make verirun'.  As with the instruction accurate simulator, the framebuffer will be
dumped to fb.bmp.

## Profiling

Type 'make profile'.  It runs the program in the verilog simulator, then prints a list of 
functions and how many instruciton issue cycles occur in each. It will also dump the internal processor performance counters.

This requires c++filt to be installed, which should be included with recent versions
of binutils.

## Debugging
### Finding crash locations<commit_msg>Minor tweak<commit_after># Basic operation

This is a simple 3d rendering engine.  There are currently a few hard-coded objects (torus, cube, and teapot) 
which can be selected by changing #defines at the top of main.cpp.

Rendering proceeds in two phases.  At the end of each phase, threads will block at a barrier until all 
other threads are finished.
- Geometry: the vertex shader is run on sets of vertex attributes.  It produces an array 
of vertex parameters.  Vertices are divided between threads, each of which processes 16 at a time (one
vertex per vector lane). There are up to 64 vertices in progress simultaneously per core (16 vertices
times four threads).
- Pixel: Triangles are rasterized and the vertex parameters are interpolated across
them.  The interpolated parameters are fed to the pixel shader, which returns color
values.  These values are blended and written back to the frame buffer.  Each thread
works on a single 64x64 tile of the screen at a time to ensure it is cache resident.
The rasterizer recursively subdivides triangles down to 4x4 squares (16 pixels). Each pixel
corresponds to a vector lane.  Similar to the geometry phase, 64 pixels are being processed
simultaneously.

The frame buffer is hard coded at location 0x100000 (1MB).

# How to run

- Install prerequisites mentioned in README at top level of project.

## Using instruction accurate simulator

This is the easiest way to run the engine and has the fewest external tool dependencies. It also executes fastest. From within this folder, type 'make run' to build and execute the project.  It will write the final contents of the framebuffer in fb.bmp.

It is also possible to see the output from the program in realtime in a Window if running on a Mac.  Once everything is built, run the following command:
<pre>
../../tools/simulator/simulator -m gui -w 640 -h 480 WORK/program.hex
</pre>

## Using Verilog model

Type 'make verirun'.  As with the instruction accurate simulator, the framebuffer will be
dumped to fb.bmp.

## Profiling

Type 'make profile'.  It runs the program in the verilog simulator, then prints a list of 
functions and how many instruciton issue cycles occur in each. It will also dump the internal processor performance counters.

This requires c++filt to be installed, which should be included with recent versions
of binutils.

## Debugging
### Finding crash locations
{'fraction_non_alphanumeric': 0.04262432093606352, 'fraction_numerical': 0.012954450480568324, 'mean_word_length': 4.147311827956989, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3285031', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1180, 'n_words': 754}