-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cython perf simplification #861
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8595bb5
complete rewrite of cython files
zerothi bd8f23f
offloaded NC/SO calculations to simple routines
zerothi 1cba3e2
redid fold_csr_matrix for much better perf
zerothi 487bb54
fixed print-out of cmake-variables and ensured Fortran is enabled
zerothi 7293726
added the changelog
zerothi 53742cf
cleaned spin-box extraction of matrix data
zerothi ee3a826
fixed handling complex matrices in sisl
zerothi 71c2c47
removed unused variable
zerothi b02db45
fixed wrong object usage in mulliken extraction
zerothi 10ada5f
added explanation of how transform works
zerothi 95370a9
fixed nc compilation with complex numbers
zerothi f6df3fb
wrong usage of siesta2sisl
zerothi cc750c6
added more tests for dtype conversion
zerothi 6fedebb
fixed bug in mock netCDF4
zerothi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Here we test and check the performance of the `Hk` implementation." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"from pathlib import Path\n", | ||
"import numpy as np\n", | ||
"import sisl as si\n", | ||
"\n", | ||
"files = Path(os.environ[\"SISL_FILES_TESTS\"])\n", | ||
"siesta = files / \"siesta\"\n", | ||
"\n", | ||
"N = 10" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"H = si.Hamiltonian.read(siesta / \"Si_pdos_k\" / \"Si_pdos.TSHS\").tile(N, 0).tile(N, 1)\n", | ||
"\n", | ||
"%timeit H.Hk()\n", | ||
"%timeit H.Hk([0.1] * 3)\n", | ||
"%timeit H.Hk(format=\"array\")\n", | ||
"%timeit H.Hk([0.1] * 3, format=\"array\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"H = si.Hamiltonian.read(siesta / \"Pt2_soc\" / \"Pt2_xx.TSHS\").tile(N, 0).tile(N // 2, 1)\n", | ||
"\n", | ||
"%timeit H.Hk()\n", | ||
"%timeit H.Hk([0.1] * 3)\n", | ||
"%timeit H.Hk(format=\"array\")\n", | ||
"%timeit H.Hk([0.1] * 3, format=\"array\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.11.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
""" | ||
Shared header for fused dtypes | ||
""" | ||
cimport cython | ||
|
||
import numpy as np | ||
|
||
cimport numpy as cnp | ||
from numpy cimport ( | ||
complex64_t, | ||
complex128_t, | ||
float32_t, | ||
float64_t, | ||
int8_t, | ||
int16_t, | ||
int32_t, | ||
int64_t, | ||
uint8_t, | ||
uint16_t, | ||
uint32_t, | ||
uint64_t, | ||
) | ||
|
||
# Generic typedefs for sisl internal naming convention | ||
ctypedef size_t size_st | ||
ctypedef Py_ssize_t ssize_st | ||
|
||
|
||
ctypedef fused ints_st: | ||
int | ||
long | ||
|
||
|
||
ctypedef fused floats_st: | ||
float | ||
double | ||
|
||
|
||
ctypedef fused complexs_st: | ||
float complex | ||
double complex | ||
|
||
|
||
ctypedef fused floatcomplexs_st: | ||
float | ||
double | ||
float complex | ||
double complex | ||
|
||
|
||
# We need this fused data-type to omit complex data-types | ||
ctypedef fused reals_st: | ||
int | ||
long | ||
float | ||
double | ||
|
||
ctypedef fused numerics_st: | ||
int | ||
long | ||
float | ||
double | ||
float complex | ||
double complex | ||
|
||
ctypedef fused _type2dtype_types_st: | ||
short | ||
int | ||
long | ||
float | ||
double | ||
float complex | ||
double complex | ||
float32_t | ||
float64_t | ||
#complex64_t # not usable... | ||
#complex128_t | ||
int8_t | ||
int16_t | ||
int32_t | ||
int64_t | ||
uint8_t | ||
uint16_t | ||
uint32_t | ||
uint64_t | ||
|
||
|
||
cdef object type2dtype(const _type2dtype_types_st v) | ||
|
||
|
||
ctypedef fused _inline_sum_st: | ||
short | ||
int | ||
long | ||
int16_t | ||
int32_t | ||
int64_t | ||
uint16_t | ||
uint32_t | ||
uint64_t | ||
|
||
cdef ssize_st inline_sum(const _inline_sum_st[::1] array) noexcept nogil |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
'import *' may pollute namespace Note