validation.cython

validation.cython.dotpy

teachcompute.validation.cython.dotpy.pydot(va, vb)[source][source]

Implements the dot product between two vectors.

Paramètres:
  • va – first vector

  • vb – second vector

Renvoie:

dot product

validation.cython.dot_blas_lapack

teachcompute.validation.cython.dot_blas_lapack.cblas_ddot(double[::1] x, double[::1] y)

Computes a dot product with cblas_ddot.

Paramètres:
  • x – first vector, dtype must be float64

  • y – second vector, dtype must be float64

Renvoie:

dot product

teachcompute.validation.cython.dot_blas_lapack.cblas_sdot(float[::1] x, float[::1] y)

Computes a dot product with cblas_sdot.

Paramètres:
  • x – first vector, dtype must be float32

  • y – second vector, dtype must be float32

Renvoie:

dot product

validation.cython.dot_cython

float32

teachcompute.validation.cython.dot_cython.dot_product(va, vb)

Python dot product but in cython file.

Paramètres:
  • va – first vector

  • vb – second vector

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.sdot_cython_array(const float[::1] va, const float[::1] vb)

dot product implemented with C types.

Paramètres:
  • va – first vector, dtype must be float32

  • vb – second vector, dtype must be float32

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.sdot_cython_array_optim(const float[::1] va, const float[::1] vb)

dot product implemented with C types with disabled checkings (see compiler directives).

Paramètres:
  • va – first vector, dtype must be float32

  • vb – second vector, dtype must be float32

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.sdot_array(const float[::1] va, const float[::1] vb)

dot product implemented with C types with disabled checkings (see compiler directives), and nogil. It is a wrapper for a C function as they cannot be exposed to the python world (gil is disabled).

Paramètres:
  • va – first vector, dtype must be float32

  • vb – second vector, dtype must be float32

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.sdot_array_16(const float[::1] va, const float[::1] vb)

dot product implemented with C types with disabled checkings (see compiler directives), and nogil. It is a wrapper for a C function as they cannot be exposed to the python world (gil is disabled). Computation is done 16x16 to benefit from branching.

Paramètres:
  • va – first vector, dtype must be float32

  • vb – second vector, dtype must be float32

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.sdot_array_16_sse(const float[::1] va, const float[::1] vb)

dot product implemented with C types with disabled checkings (see compiler directives), and nogil. It is a wrapper for a C function as they cannot be exposed to the python world (gil is disabled). Computation is done 16x16 to benefit from branching and uses AVX instructions.

Paramètres:
  • va – first vector, dtype must be float32

  • vb – second vector, dtype must be float32

Renvoie:

dot product

double = float64

teachcompute.validation.cython.dot_cython.ddot_cython_array(const double[::1] va, const double[::1] vb)

dot product implemented with C types.

Paramètres:
  • va – first vector, dtype must be float64

  • vb – second vector, dtype must be float64

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.ddot_cython_array_optim(const double[::1] va, const double[::1] vb)

dot product implemented with C types with disabled checkings (see compiler directives).

Paramètres:
  • va – first vector, dtype must be float64

  • vb – second vector, dtype must be float64

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.ddot_array(const double[::1] va, const double[::1] vb)

dot product implemented with C types with disabled checkings (see compiler directives), and nogil. It is a wrapper for a C function as they cannot be exposed to the python world (gil is disabled).

Paramètres:
  • va – first vector, dtype must be float64

  • vb – second vector, dtype must be float64

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.ddot_array_16(const double[::1] va, const double[::1] vb)

dot product implemented with C types with disabled checkings (see compiler directives), and nogil. It is a wrapper for a C function as they cannot be exposed to the python world (gil is disabled). Computation is done 16x16 to benefit from branching.

Paramètres:
  • va – first vector, dtype must be float64

  • vb – second vector, dtype must be float64

Renvoie:

dot product

teachcompute.validation.cython.dot_cython.ddot_array_16_sse(const double[::1] va, const double[::1] vb)

dot product implemented with C types with disabled checkings (see compiler directives), and nogil. It is a wrapper for a C function as they cannot be exposed to the python world (gil is disabled). Computation is done 16x16 to benefit from branching and uses AVX instructions.

Paramètres:
  • va – first vector, dtype must be float64

  • vb – second vector, dtype must be float64

Renvoie:

dot product

openmp

teachcompute.validation.cython.dot_cython_omp.get_omp_max_threads()

Returns the number of threads.

teachcompute.validation.cython.dot_cython_omp.ddot_cython_array_omp(const double[::1] va, const double[::1] vb, int chunksize=32, int schedule=0)

dot product implemented with cython and C types using prange (openmp in cython).

Paramètres:
  • va – first vector, dtype must be float64

  • vb – second vector, dtype must be float64

  • chunksize – see prange

  • schedule – 0 simple prange, 1 for “static”, 2 for “dynamic”

Renvoie:

dot product

teachcompute.validation.cython.dot_cython_omp.ddot_array_openmp(const double[::1] va, const double[::1] vb)

dot product using openmp inside C++ code.

Paramètres:
  • va – first vector, dtype must be float64

  • vb – second vector, dtype must be float64

Renvoie:

dot product

teachcompute.validation.cython.dot_cython_omp.ddot_array_openmp_16(const double[::1] va, const double[::1] vb)

dot product using openmp inside C++ code, parallelizes 16x16 computation.

Paramètres:
  • va – first vector, dtype must be float64

  • vb – second vector, dtype must be float64

Renvoie:

dot product

validation.cython.experiment_cython

teachcompute.validation.cython.experiment_cython.pyfilter_dmax(va, mx)

Replaces all value superior to mx by mx. Python inside cython.

Paramètres:
  • va – first vector

  • mx – maximum

teachcompute.validation.cython.experiment_cython.filter_dmax_cython(double[::1] va, double mx)

Replaces all value superior to mx by mx. Simple cython.

Paramètres:
  • va – first vector

  • mx – maximum

teachcompute.validation.cython.experiment_cython.filter_dmax_cython_optim(double[::1] va, double mx)

Replaces all value superior to mx by mx. Simple cython with no bound checked, no wrap around.

Paramètres:
  • va – first vector

  • mx – maximum

teachcompute.validation.cython.experiment_cython.cyfilter_dmax(double[::1] va, double mx)

Replaces all value superior to mx by mx. Wraps a C function implemented in cython.

Paramètres:
  • va – first vector

  • mx – maximum

teachcompute.validation.cython.experiment_cython.cfilter_dmax(double[::1] va, double mx)

Replaces all value superior to mx by mx. Wraps a C function implemented in C.

Paramètres:
  • va – first vector

  • mx – maximum

teachcompute.validation.cython.experiment_cython.cfilter_dmax2(double[::1] va, double mx)

Replaces all value superior to mx by mx. Wraps a C function implemented in C, but uses operator ? : instead of keyword if.

Paramètres:
  • va – first vector

  • mx – maximum

teachcompute.validation.cython.experiment_cython.cfilter_dmax4(double[::1] va, double mx)

Replaces all value superior to mx by mx. Wraps a C function implemented in C, but uses operator ? : instead of keyword if. Goes 4 by 4.

Paramètres:
  • va – first vector

  • mx – maximum

teachcompute.validation.cython.experiment_cython.cfilter_dmax16(double[::1] va, double mx)

Replaces all value superior to mx by mx. Wraps a C function implemented in C, but uses operator ? : instead of keyword if. Goes 16 by 16.

Paramètres:
  • va – first vector

  • mx – maximum

validation.cython.mul_cython_omp

teachcompute.validation.cython.mul_cython_omp.dmul_cython_omp(const double[:, :] va, const double[:, :] vb, int algo=0, int parallel=0, int b_trans=0)

matrix multiplication product implemented with cython and C types using prange (openmp in cython).

Paramètres:
  • va – first matrix, dtype must be float64

  • vb – second matrix, dtype must be float64

  • algo – algorithm (see below)

  • parallel – kind of parallelization (see below)

Renvoie:

matrix multiplication

See mul_cython_omp.pyx.

validation.cython.td_mul_cython

teachcompute.validation.cython.td_mul_cython.multiply_matrix(m1, m2)

Matrix multiplication

teachcompute.validation.cython.td_mul_cython.c_multiply_matrix_parallel(double[:, :] m1, double[:, :] m2)

Matrix multiplication calling the cython version

teachcompute.validation.cython.td_mul_cython.c_multiply_matrix(double[:, :] m1, double[:, :] m2)

Matrix multiplication calling the cython version

teachcompute.validation.cython.td_mul_cython.c_multiply_matrix_parallel_transposed(double[:, ::1] m1, double[:, ::1] m2)

validation.cython.vector_function_cy

teachcompute.validation.cython.vector_function_cy.vector_add_c(v1, v2)

Computes the addition of two tensors of the same shape.

Paramètres:
  • v1 – first tensor

  • v2 – second tensor

Renvoie:

result.