Skip to content

Commit

Permalink
Update licensing information
Browse files Browse the repository at this point in the history
  • Loading branch information
jussienko committed Feb 25, 2025
1 parent 60bc9f2 commit a7625fd
Show file tree
Hide file tree
Showing 317 changed files with 1,597 additions and 468 deletions.
8 changes: 8 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
All material Copyright (c) CSC - IT Center for Science Ltd. <www.csc.fi> unless otherwise noted.

All text and image material licensed under Creative Commons BY-NC-SA 4.0 unless
otherwise noted.

All code samples licensed under MIT license unless otherwise noted.

See LICENSES/ and individual file headers for more details.
30 changes: 0 additions & 30 deletions LICENSE

This file was deleted.

170 changes: 170 additions & 0 deletions LICENSES/CC-BY-NC-SA-4.0.txt

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions LICENSES/MIT.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MIT License

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
SPDX-License-Identifier: CC-BY-NC-SA-4.0
-->

# Python in High Performance Computing

Exercise material and model answers for the CSC course "Python in High Performance Computing". The course is part of PRACE Training activity at CSC.
Expand Down
6 changes: 6 additions & 0 deletions cython/c-functions/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
SPDX-License-Identifier: CC-BY-NC-SA-4.0
-->

## Using C-functions

Fibonacci numbers are a sequence of integers defined by the recurrence
Expand Down
4 changes: 4 additions & 0 deletions cython/c-functions/fib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

def fibonacci(n):
if n < 2:
return n
Expand Down
4 changes: 4 additions & 0 deletions cython/c-functions/solution/fib.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

cpdef int fibonacci(int n):
if n < 2:
return n
Expand Down
4 changes: 4 additions & 0 deletions cython/c-functions/solution/fib_py.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from functools import lru_cache

def fibonacci(n):
Expand Down
4 changes: 4 additions & 0 deletions cython/c-functions/solution/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from distutils.core import setup, Extension
from Cython.Build import cythonize

Expand Down
4 changes: 4 additions & 0 deletions cython/c-functions/solution/test_fib.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from fib import fibonacci
from fib_py import fibonacci as fibonacci_py, fibonacci_cached
from timeit import repeat
Expand Down
6 changes: 6 additions & 0 deletions cython/heat-equation/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
SPDX-License-Identifier: CC-BY-NC-SA-4.0
-->

## Optimising heat equation with Cython

### Creating a Cython extension
Expand Down
4 changes: 4 additions & 0 deletions cython/heat-equation/heat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

import numpy as np
import matplotlib
matplotlib.use('Agg')
Expand Down
4 changes: 4 additions & 0 deletions cython/heat-equation/heat_main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from __future__ import print_function
import time
import argparse
Expand Down
6 changes: 6 additions & 0 deletions cython/heat-equation/profile.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
SPDX-License-Identifier: CC-BY-NC-SA-4.0
-->

## Example profile for heat equation solver

```
Expand Down
50 changes: 50 additions & 0 deletions cython/heat-equation/solution/evolve_new.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

# cython: profile=True

import numpy as np
cimport numpy as cnp

import cython

@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
cdef laplacian(cnp.ndarray[cnp.double_t, ndim=2]u, cnp.ndarray[cnp.double_t, ndim=2]du, double dx2, double dy2):

cdef int n = u.shape[0]
cdef int m = u.shape[1]

cdef int i,j

# Multiplication is more efficient than division
cdef double dx2inv = 1. / dx2
cdef double dy2inv = 1. / dy2

for i in range(1, n-1):
for j in range(1, m-1):
du[i, j] = (u[i+1, j] - 2*u[i, j] + u[i-1, j]) * dx2inv + \
(u[i, j+1] - 2*u[i, j] + u[i, j-1]) * dy2inv



@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
def evolve(cnp.ndarray[cnp.double_t, ndim=2]u,
cnp.ndarray[cnp.double_t, ndim=2]u_previous,
double a, double dt, double dx2, double dy2):
"""Explicit time evolution.
u: new temperature field
u_previous: previous field
a: diffusion constant
dt: time step. """

laplacian(u_previous, u, dx2, dy2)
# u *= a * dt
u = u_previous + a*dt * u

u_previous[:] = u[:]

32 changes: 32 additions & 0 deletions cython/heat-equation/solution/evolve_py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

import numpy as np
from numba import jit, void, double

# @jit(void(double[:,:], double[:,:], double, double, double, double), nopython=True, cache=True, fastmath=True, error_model='numpy')
# @jit(nopython=True, cache=True, fastmath=True)
@jit(nopython=True)
def evolve(u, u_previous, a, dt, dx2, dy2):
"""Explicit time evolution.
u: new temperature field
u_previous: previous field
a: diffusion constant
dt: time step. """

n, m = u.shape

# dx2inv = 1.0 / dx2
# dy2inv = 1.0 / dy2
for i in range(1, n-1):
for j in range(1, m-1):
u[i, j] = u_previous[i, j] + a * dt * ( \
(u_previous[i+1, j] - 2*u_previous[i, j] + \
u_previous[i-1, j]) / dx2 + \
# u_previous[i-1, j]) * dx2inv + \
(u_previous[i, j+1] - 2*u_previous[i, j] + \
u_previous[i, j-1]) / dy2 )
# u_previous[i, j-1]) * dy2inv )
u_previous[:] = u[:]

4 changes: 4 additions & 0 deletions cython/heat-equation/solution/heat.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

import numpy as np
cimport numpy as cnp
import cython
Expand Down
4 changes: 4 additions & 0 deletions cython/heat-equation/solution/heat_main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from __future__ import print_function
import time
import argparse
Expand Down
4 changes: 4 additions & 0 deletions cython/heat-equation/solution/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from distutils.core import setup, Extension
from Cython.Build import cythonize

Expand Down
6 changes: 6 additions & 0 deletions cython/simple-extension/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
SPDX-License-Identifier: CC-BY-NC-SA-4.0
-->

## Simple Cython extension

### Creating a Cython extension
Expand Down
4 changes: 4 additions & 0 deletions cython/simple-extension/solution/cyt_module.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

def subtract(x, y):
result = x - y
return result
4 changes: 4 additions & 0 deletions cython/simple-extension/solution/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from distutils.core import setup, Extension
from Cython.Build import cythonize

Expand Down
6 changes: 6 additions & 0 deletions cython/static-typing/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<!--
SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
SPDX-License-Identifier: CC-BY-NC-SA-4.0
-->

## Using static typing

Continue with the simple Cython module for subtracting two numbers:
Expand Down
4 changes: 4 additions & 0 deletions cython/static-typing/cyt_module.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

def subtract(x, y):
result = x - y
return result
4 changes: 4 additions & 0 deletions cython/static-typing/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from distutils.core import setup, Extension
from Cython.Build import cythonize

Expand Down
4 changes: 4 additions & 0 deletions cython/static-typing/solution/cyt_module.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

def subtract(int x, int y):
cdef int result
result = x - y
Expand Down
4 changes: 4 additions & 0 deletions cython/static-typing/solution/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from distutils.core import setup, Extension
from Cython.Build import cythonize

Expand Down
4 changes: 4 additions & 0 deletions demos/broadcasting.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

import numpy as np

a1 = np.random.random((10,3))
Expand Down
4 changes: 4 additions & 0 deletions demos/cython/mandel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from time import time
import numpy as np

Expand Down
4 changes: 4 additions & 0 deletions demos/cython/mandel_cyt.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from time import time
import numpy as np
cimport numpy as cnp
Expand Down
4 changes: 4 additions & 0 deletions demos/cython/mandel_cyt_1.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from time import time
import numpy as np

Expand Down
4 changes: 4 additions & 0 deletions demos/cython/mandel_cyt_2.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from time import time
import numpy as np

Expand Down
4 changes: 4 additions & 0 deletions demos/cython/mandel_cyt_3.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from time import time
import numpy as np
cimport numpy as cnp
Expand Down
4 changes: 4 additions & 0 deletions demos/cython/mandel_cyt_4.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from time import time
import numpy as np
cimport numpy as cnp
Expand Down
4 changes: 4 additions & 0 deletions demos/cython/mandel_cyt_5.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# SPDX-FileCopyrightText: 2019 CSC - IT Center for Science Ltd. <www.csc.fi>
#
# SPDX-License-Identifier: MIT

from time import time
import numpy as np
cimport numpy as cnp
Expand Down
Loading

0 comments on commit a7625fd

Please sign in to comment.