實作 sorting algorithm 以熟悉演算法與程式語言。
預計實作
- bubble sort
- insertion sort
- merge sort
- quick sort
| import tvm | |
| N, M, L = 1024, 512, 64 | |
| A = tvm.placeholder((N, L), name='A') | |
| B = tvm.placeholder((M, L), name='B') | |
| k = tvm.reduce_axis((0, L), name='k') | |
| C = tvm.compute((N, M), lambda i, j: | |
| tvm.sum(A[i, k] * B[j, k], axis=k), name='C') | |
| s = tvm.create_schedule(C.op) | |
| print(tvm.lower(s, [A, B, C], simple_mode=True)) |
| int sum(int a, int b) { | |
| return a+b; | |
| } | |
| void print(int); | |
| int main() { | |
| int a = 50; | |
| int b = 50*123; |
| GLfloat quadVertices[] = { | |
| -150.0f, -150.0f, -150.0f, | |
| -150.0f, -150.0f, 150.0f, | |
| 150.0f, -150.0f, -150.0f, | |
| 150.0f, -150.0f, -150.0f, | |
| -150.0f, -150.0f, 150.0f, | |
| 150.0f, -150.0f, 150.0f | |
| }; | |
| glUniformMatrix4fv(model_p.mv, 1, GL_FALSE, value_ptr(view2 * |
| FROM ubuntu:18.04 | |
| MAINTAINER BeMg | |
| RUN apt-get update && apt-get install -y git autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk \ | |
| build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev && mkdir risc-v | |
| ENV RISCV /risc-v | |
| RUN git clone --recursive https://github.com/riscv/riscv-gnu-toolchain && \ | |
| cd riscv-gnu-toolchain && ./configure --prefix=$RISCV && make -j4 && \ | |
| rm -rf riscv-binutils && git clone --branch test git@github.com:BeMg/riscv-bintuils.git riscv-binutils && \ | |
| cd riscv-binutils && ./configure --prefix=$RISCV --target=riscv64-unknown-elf && make -j4 && make install -j4 && cd |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| int main(int argc, char *argv[]) { | |
| if (argc > 0) { | |
| printf("%s\n", argv[1]); | |
| } | |
| FILE *pfile = fopen(argv[1], "r"); |
| void loadScene(string path, string img_path, vector<Shape> &vS, vector<Material> &vM) { | |
| Assimp::Importer importer; | |
| const aiScene* scene = importer.ReadFile(path, aiProcess_Triangulate | aiProcess_FlipUVs); | |
| for (unsigned int i = 0; i < scene->mNumMaterials; ++i) | |
| { | |
| aiMaterial *material = scene->mMaterials[i]; | |
| Material Material; | |
| aiString texturePath; |
| #include <stdio.h> | |
| int test(int a[], int b[]) { | |
| asm volatile( | |
| "ld a2, 0(a0)\n\t" | |
| "ld a3, 0(a1)\n\t" | |
| "add16 a2, a2, a3 \n\t" | |
| "sd a2, 0(a0)\n\t" | |
| ); | |
| } |
| #lang racket | |
| ;; Programming Languages Homework 5 Simple Test | |
| ;; Save this file to the same directory as your homework file | |
| ;; These are basic tests. Passing these tests does not guarantee that your code will pass the actual homework grader | |
| ;; Be sure to put your homework file in the same folder as this test file. | |
| ;; Uncomment the line below and, if necessary, change the filename | |
| ;;(require "hw5") | |
| (require rackunit) |
| # Script to build RISC-V ISA simulator, proxy kernel, and GNU toolchain. | |
| # Tools will be installed to $RISCV. | |
| if [ "x$RISCV" = "x" ] | |
| then | |
| echo "Please set the RISCV environment variable to your preferred install path." | |
| exit 1 | |
| fi | |
| # Use gmake instead of make if it exists. |