Skip to content

Commit

Permalink
Final upldates for 2.1.3 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
casevh committed Dec 5, 2022
1 parent a8f259f commit eeccd98
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
23 changes: 22 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,15 +1,36 @@
Introduction
------------

gmpy2 is an optimized, C-coded Python extension module that supports fast
multiple-precision arithmetic. gmpy2 is based on the original gmpy module.
gmpy2 adds support for correctly rounded multiple-precision real arithmetic
(using the MPFR library) and complex arithmetic (using the MPC library).

Version 2.1.x Status
--------------------

gmpy2 2.1 was extensively refactored. Some of the significant changes are:

* Support for thread-safe contexts and context methods
* Interoperability with Cython extensions
* mpz and mpq operation can release the GIL (controlled by the conntext)
* mpz and mpq operation can release the GIL
* The current implementation is experimental
* Improved argument processing

The gmpy2 2.1 series will be the last to offer compatibility with Python 2.7.
Release 2.1.3 is the last planned release of the 2.1 series.

Version 2.2 Plans
-----------------

Version 2.2 will drop support for Python 2.7 and older Python 3.x versions.

The primary development focus will be on functions that operate on lists and
release the GIL. See powmod_base_list and powmod_exp_list as examples.

Availability
------------

gmpy2 is available at https://pypi.python.org/pypi/gmpy2/

Documentation is available at https://gmpy2.readthedocs.io/en/latest/
Expand Down
9 changes: 4 additions & 5 deletions demo/parallel_powmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import concurrent.futures
import time

# Test parallel computation of gmpy2.powmod()
# Test parallel computation of gmpy2.powmod_base_list()

# The demo code is not (yet) optimal since it doesn't take advantage of
# read-only access to data list that is shared across all threads.
Expand All @@ -13,7 +13,6 @@ def create_tests(num_items = 100000, bits = 1000):
e = gmpy2.mpz_urandomb(rand, bits)
m = gmpy2.mpz_urandomb(rand, bits)
big_list = [gmpy2.mpz_urandomb(rand, bits) for _ in range(num_items)]
e = 65537
return big_list, e, m

# Partition big_list into a new list containing a number of sub-list with
Expand Down Expand Up @@ -53,7 +52,7 @@ def powmod_vector_nogil(index, vector, e, m):

# Run threaded versions.
def run_test(function, big_list, e, m, threads, release_gil = True):
over_split = 4
over_split = 8
size = len(big_list) // (over_split * threads) + bool(len(big_list) % (over_split * threads))
split_list = partition_list(big_list, size)
total_thread_time = 0
Expand All @@ -69,13 +68,13 @@ def run_test(function, big_list, e, m, threads, release_gil = True):
return time.time() - walltime_start, total_thread_time

if __name__ == "__main__":
big_list, e, m = create_tests(100000, 32000)
big_list, e, m = create_tests(100000, 1024)

# Run a baseline test with releasing the GIL.
# print("Baseline test without releasing the GIL. ", powmod_list_gil(big_list, e, m)[0])

# Specify the number of threads to use.
test_threads = [1,2,4,8,15,16,24,31,32]
test_threads = [1,2,4,8]
# The following demo code is disabled by default. It high-lights the inefficiency of
# releasing the GIL for functions that execute fairly quicky
for i in range(0):
Expand Down

0 comments on commit eeccd98

Please sign in to comment.