This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Для выбора ответа в {} написать +. | |
| В каждом вопросе только один верный ответ. | |
| # Threads, processes | |
| 1. Каким вызовом создастся новый поток? | |
| {} A. CreateThread | |
| {} B. vfork |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // with exact num of chans | |
| func waitAllChans(chans [3]chan int) { | |
| for { | |
| select { | |
| case a, ok := <-chans[0]: | |
| if !ok { | |
| chans[0] = nil | |
| break | |
| } | |
| fmt.Println("chan", 0, "return val", a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // with exact num of chans | |
| func waitAllChans(chans [3]chan int) { | |
| for { | |
| select { | |
| case a, ok := <-chans[0]: | |
| if !ok { | |
| chans[0] = nil | |
| break | |
| } | |
| fmt.Println("chan", 0, "return val", a) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // with random num of chans | |
| func waitAllChans(chans []chan int) { | |
| for { | |
| closedChans := 0 | |
| for _, currCh := range chans { | |
| select { | |
| case val, ok := <-currCh: | |
| if !ok { | |
| closedChans += 1 | |
| break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fib(n: int): | |
| if n <= 0: | |
| return 0 | |
| if n == 1: | |
| return 1 | |
| return fib(n - 1) + fib(n - 2) | |
| n = int(input()) | |
| result = fib(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fib(n: int): | |
| if n <= 0: | |
| return 0 | |
| if n == 1: | |
| return 1 | |
| return fib(n - 1) + fib(n - 2) | |
| n = int(input()) | |
| result = fib(n) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| B1="/home/am/dev/cpp/playground/bench/1000_1.txt" | |
| B2="/home/am/dev/cpp/playground/bench/1000_2.txt" | |
| OUTFILE="/home/am/dev/cpp/playground/res.txt" | |
| MATRIX_SIZE=1440 | |
| ALGORITHM="-r" # "-c" "-s" | |
| LOG_DIR="home/am/dev/cpp/playground/logs/" | |
| mpirun --hostfile hostfile -np 8 ./prog -- "${ALGORITHM}" "${OUTFILE}" "${LOG_DIR}" "${B1}" "${B2}" ${MATRIX_SIZE} | |
| # check correctness | |
| python3 ./check.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // #include <cstdint> | |
| #include <fstream> | |
| #include <iostream> | |
| #include <vector> | |
| #include <chrono> | |
| #include <mpi.h> | |
| #include <cmath> | |
| inline void show(const std::vector<int> &v) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <fstream> | |
| #include <cstdlib> | |
| #include <ctime> | |
| int main(int argc, char **argv) | |
| { | |
| if (argc != 2) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| n = int(input()) | |
| matrix1 = np.loadtxt("/home/am/dev/cpp/playground/bench/1000_1.txt") | |
| matrix2 = np.loadtxt("/home/am/dev/cpp/playground/bench/1000_2.txt") | |
| matrix3 = np.loadtxt("/home/am/dev/cpp/playground/res.txt") | |
| result = matrix1 @ matrix2 |