[ec2-user ~]$ wget http://ftp.jaist.ac.jp/pub/CTAN/systems/texlive/tlnet/install-tl-unx.tar.gz
[ec2-user ~]$ tar xzf install-tl-unx.tar.gz
[ec2-user ~]$ cd install-tl-2017xxxx
[ec2-user ~]$ sudo ./install-tl
Below you can find some sample template code which you can use to run multicore Python computations.
# =================================================================================================
# Imports
# =================================================================================================
import multiprocessing as mp
This file contains 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
for y in range(0, 1000): | |
for m in range(1,13): | |
max_day = 32 | |
# Month length correction | |
if m == 11 or m == 9 or m == 6 or m == 4: | |
max_day = 31 | |
# Leap year correction | |
elif m == 2: | |
y_actual = y + 2000 |
This file contains 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
sysctl -n machdep.cpu.brand_string | |
# Example output: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz |
On my 2014 MacBook Pro (2.5 GHz), this vectorized version is about 250 times faster when used for a large numbers of triangles compared to the original algorithm. You can also parallelize this code over multiple threads, but due to the large overhead of creating a thread pool, this is only really useful when you have a very large number of rays.
I also tried to vectorize the rays, instead of using a loop. I did this by using:
np.reshape(np.array(np.meshgrid(np.arange(0, len(ray_direction), 1), np.arange(0, len(triangles_vertices), 1))), (2, resulting_array_length))
to create all combinations of indices of the rays and the triangles. However, using this process, combined with using np.take()
to actually create these combinations is about twice as slow as the code below.
This file contains 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
void divide (float a, float b, float *c) | |
{ | |
#pragma HLS interface s_axilite port=a | |
#pragma HLS interface s_axilite port=b | |
#pragma HLS interface s_axilite port=c | |
#pragma HLS interface ap_ctrl_none port=return | |
*c = a / b; | |
} |
This file contains 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
from typing import List, Any, Callable | |
def zip_with (func: Callable[[Any, Any], Any], list1: List[Any], list2: List[Any]) -> Any: | |
""" | |
>>> zip_with (lambda x, y: x + y, [1, 2, 3], [4, 5, 6]) | |
[5, 7, 9] | |
""" | |
return [func (x, y) for x, y in zip (list1, list2)] | |
This file contains 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 torch | |
import torch.nn as nn | |
import torchvision | |
from torch.utils.data import Dataset | |
class SequentialMNIST(Dataset): | |
def __init__(self, MNIST_dataset: torchvision.datasets.MNIST): | |
self.MNIST_dataset = MNIST_dataset |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
"""Data taken from paper: Computing's Energy Problem (and what we can do about it) - Mark Horowitz | |
All output energies are in pJ (pico Joule) | |
""" | |
import math | |
E_INT_ADD_PER_BIT = (0.03 / 8 + 0.1 / 32) / 2 | |
OlderNewer