Giter Site home page Giter Site logo

andrewt0301 / hse-acos-course Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 27.0 793.56 MB

Materials for the "Computer Architecture and Operating Systems" course taught at Faculty of Computer Science of Higher School of Economics

Home Page: https://andrewt0301.github.io/hse-acos-course/

License: Apache License 2.0

Assembly 85.28% Python 14.72%
assembly-language c-language computer-architecture linux operating-systems risc-v

hse-acos-course's People

Contributors

adamxrvn avatar andrewt0301 avatar nchechulin avatar pshakhmin avatar spnya avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hse-acos-course's Issues

OS Test Note

Powering a negative number into a non-integer power can result in NaN:

andrewt@LAPTOP-5GPL0IVV:~/src$ cat test.c
#include <math.h>
#include <stdio.h>

int main() {
   printf("x = %f\n", pow(-7, 1.23));
   return 0;
}
andrewt@LAPTOP-5GPL0IVV:~/src$ gcc test.c -o test -lm
andrewt@LAPTOP-5GPL0IVV:~/src$ ./test
x = -nan

We consider it is OK.

Quizzes 2023

Quiz authors:

  • Oleg Malchenko
  • Daria Lapko
  • Vladislav Kirichok
  • Andy Xu
  • Artem Borisov
  • Nikolay Chechulin

CA quizzes:

  1. Vladislav Kirichok
  2. Oleg Malchenko
  3. Andy Xu
  4. Daria Lapko
  5. Nikolay Chechulin
  6. Artem Borisov

OS quizzes:

Final Test Issue

Notes on Final Test Programming Task

Task

The programming task as specified here:

Write a RISC-V assembly program that inputs integer value x (assumed non-negative) and calculates the value of the f(x) mathematical function according to the specified equations. f(x) must be implemented as a function and must comply with RISC-V calling conventions.

The implemented function must use callee-saved registers (s0, s1, etc.) to store intermediate results of calculations. These registers must be saved to the stack and restored when the function returns.

Variant

Group 202, variant 7. Taken from here:

f(x) = 6 * x**5 + 4 * x**3 - 5 * x**2 + 7 * x if x < 5
f(x) = 4 if x >= 5
f(x) = 7**x + -2 if x == 6
f(x) = -1 * x + 10 if x > 9

This task means to create a RISC-V assembly program that does the same as this Python program:

def f(x):
    if x < 5:
        return 6 * x ** 5 + 4 * x ** 3 - 5 * x ** 2 + 7 * x
    if x > 9:
        return -1 * x + 10
    if x == 6:
        return 7 ** x + -2
    return 4  # if x >= 5


x = int(input())
print(f(x))

Expected results:

x = 1
f(x) = 12

x = 5
f(x) = 4

x = 6
f(x) = 117647

x = 7
f(x) = 4

x = 11
f(x) = -1

Solution

#попытка  f(x) = 6 * x**5 + 4 * x**3 - 5 * x**2 + 7 * x if x < 5
.text
li a7, 5 
ecall
mv t0, a0  

addi t1, zero, 6 
addi t2, zero, 4
addi t3, zero, 5
addi t4, zero, zero

	j compare
loop:
	mul t0, t0, t0
	addi t4, zero, 1
compare:
	blt t4, t2 loop

bge t0, t3, endif
mv a0, t4
li a7, 1
ecall 
endif:


# f(x) = 4 if x >= 5
.text
li a7, 5 
ecall
mv t0, a0  

addi t1, zero, 5
addi t2, zero, 4

blt t0, t1, endif
mv a0, t2
li a7, 1
ecall 
endif:

# f(x) = 7**x + -2 if x == 6
.text
li a7, 5 
ecall
mv t0, a0  

addi t1, zero, 7 
addi t2, zero, 2
addi t3, zero, 6

mul t4, t0, t0
mul t4, t4, t1
sub t4, t4, t2

bne t0, t3, endif
mv a0, t4
li a7, 1
ecall 
endif:

#  f(x) = -1 * x + 10 if x > 9
.text
li a7, 5 
ecall
mv t0, a0  

addi t1, zero, 9 
addi t2, zero, -1
mul t3, t0, t2
addi t3, t3, 10

bge t1, t0, endif
mv a0, t3
li a7, 1
ecall 
endif:

Notes

  1. There is no f(x) function: -2
  2. Callee-saved registers are not saved/loaded to stack: -1
  3. There are 4 programs:
    • f(x) = 6 * x**5 + 4 * x**3 - 5 * x**2 + 7 * x if x < 5 - does not work, -2
    • f(x) = 4 if x >= 5 - OK
    • f(x) = 7**x + -2 if x == 6 - wrong, 250 vs. 117647, -2
    • f(x) = -1 * x + 10 if x > 9 - OK

Result

10 - 2 - 1 - 2 - 2 = 3

Question

я продублирую что я хотел вам предложить насчет штрафов за просрочку: допустим за каждую неделю вы убираете на данный момент по 25%, мое же предложение состоит в том чтобы эти 25% поделить на 7 и считать проценты штрафа за каждый день, просто кто то может просрочить контест на пару часов и потерять существенное количество баллов, а данная система смягчит мелкие опоздания

FLOPS

https://www.intel.com/content/www/us/en/support/articles/000057415/processors.html

Where Can I Find Information about FLOPS Per Cycle for Intel® Processors?

Summary
FLOPS per Cycle no longer available; instead there is GFLOPS (Giga-FLOPS).

Description
How many FLOPS per cycle does my Intel® Processor get?

Resolution
Please be aware that Intel no longer makes FLOPS (Floating Point Operations) per cycle information available for Intel® processors. Instead, Intel publishes GFLOPS (Giga-FLOPS) and APP (Adjusted Peak Performance) information. For details, see the Export Compliance Metrics for Intel® Microprocessors web page.

[Enhancement]: Rewrite benchmarks for Java and Python

While it's not a case for natively compiled languages like C, JITted languages (like Java) require much more careful benchmarking, taking into account JITting time and GC pauses (as well as possible standard deviation (due to many factors), tiered compilation, etc).

Broken link in HW1

In homework-1 we have a bunch of links to implementations of matrix multiplication. The last link is incorrect: the title says C incorrectly optimized (jki) while the link actually leads to ikj

[Bug]: C seems to be compiled in default mode

C takes 2.7 sec at best according to the presentation (on my machine it takes 3.4 without flags).

Instead, if you supply optimization flags, it'd take 0.7 sec.

To benchmark fairly, one would need to compile it like this:

gcc matrix_jki.c -O3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.