From 48a6aa8713c994ce5aa618d758618dd93f6043b1 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Fri, 2 Oct 2020 15:47:27 +0300 Subject: [PATCH 01/14] Importing MPI locally --- lyncs_DDalphaAMG/solver.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lyncs_DDalphaAMG/solver.py b/lyncs_DDalphaAMG/solver.py index ea28d0c..d4b5b36 100644 --- a/lyncs_DDalphaAMG/solver.py +++ b/lyncs_DDalphaAMG/solver.py @@ -5,6 +5,8 @@ https://github.com/sbacchio/DDalphaAMG/blob/master/src/DDalphaAMG.h """ +# pylint: disable=import-outside-toplevel + __all__ = [ "Solver", ] @@ -14,7 +16,6 @@ from os.path import isfile, realpath, abspath import numpy from cppyy import nullptr -from mpi4py import MPI from lyncs_mpi import default_comm, CartesianClass from lyncs_mpi.abc import Array, Global, Constant from lyncs_cppyy.ll import cast, to_pointer, addressof @@ -79,6 +80,8 @@ def __init__( rnd_seeds: list(int) An int per MPI process (list of length comm.size) """ + from mpi4py import MPI + self._init_params = lib.DDalphaAMG_init() self._run_params = lib.DDalphaAMG_parameters() self._status = lib.DDalphaAMG_status() @@ -251,6 +254,8 @@ def setup_status(self): @property def comm(self): "Returns the MPI communicator used by the library." + from mpi4py import MPI + comm = MPI.Comm() comm_ptr = to_pointer(MPI._addressof(comm), "MPI_Comm*") lib.MPI_Comm_free(comm_ptr) @@ -419,6 +424,8 @@ def get_lattice_partitioning(global_lattice, block_lattice=None, procs=None, com raise ValueError("procs must be a list of length 4 (T, Z, Y, X)") if comm is not None: + from mpi4py import MPI + if not isinstance(comm, MPI.Comm): raise TypeError(f"Expected an MPI.Comm but got {type(comm)}") From 231ac1f99fd322d353ac61ffb57a2ca5168774a4 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Mon, 5 Oct 2020 18:30:31 +0300 Subject: [PATCH 02/14] Adding issue template --- .github/ISSUE_TEMPLATE/bug_report.md | 50 ++++++++++++++++++++++++++++ setup.py | 1 + 2 files changed, 51 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..bd4aa3e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,50 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG] Add description" +labels: bug +assignees: '' + +--- + +Before reporting a bug, please make sure you are using the latest version +of all the lyncs packages. Use the following command to update them: + +``` +pip install [--user] --upgrade $(lyncs_packages) +``` + +If the library is failing due to linking problems or changes in the system, +you can recompile all the source code in the following way: + +``` +pip install [--user] --force-reinstall --no-cache-dir $(lyncs_packages) +``` + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +If applicable, list the steps to reproduce the behavior: + +**Error message / Output** +If applicable, paste here the error messages / output you get. + +
+ Click to expand! + + ``` + # PASTE HERE + ``` +
+ +**Installed versions** +Paste here the output of `lyncs_packages -v`. + +
+ Click to expand! + + ``` + # PASTE HERE + ``` +
diff --git a/setup.py b/setup.py index 2480914..c9b32ab 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ "lyncs-cppyy", "lyncs-utils", "lyncs-clime", + "lyncs-setuptool", ], extras_require={ "test": ["pytest", "pytest-cov", "pytest-benchmark"], From aea77213018803e11ffdb9c65d1c28e3803111e4 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Mon, 5 Oct 2020 18:30:44 +0300 Subject: [PATCH 03/14] Adding test for data movement --- test/test_solver.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/test_solver.py b/test/test_solver.py index 4c29c34..9c96889 100644 --- a/test/test_solver.py +++ b/test/test_solver.py @@ -161,3 +161,36 @@ def test_errors(): with raises(ValueError): Solver(global_lattice=[4, 4, 4, 4], rnd_seeds=[1, 2]) + + +def test_data_movement(): + client = Client(4) + procs = [2, 1, 1, 1] + comm1 = client.create_comm(2).create_cart(procs) + comm2 = client.create_comm(2, exclude=comm1.workers).create_cart(procs) + + solver1 = Solver( + global_lattice=[4, 4, 4, 4], + block_lattice=[2, 2, 2, 2], + procs=procs, + kappa=0.1, + comm=comm1, + ) + solver2 = Solver( + global_lattice=[4, 4, 4, 4], + block_lattice=[2, 2, 2, 2], + procs=procs, + kappa=0.1, + comm=comm2, + ) + + conf = solver1.read_configuration("test/conf.random") + plaq1 = solver1.set_configuration(conf) + assert np.isclose(plaq1, 0.13324460568521923) + + plaq2 = solver2.set_configuration(conf) + assert np.isclose(plaq1, plaq2) + + vec = solver1.random() + sol = solver1.solve(vec) + assert allclose(solver2.D(sol), vec) From ed92e7c2bb6e7f6658f704183b12499578c5ff61 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 16:03:29 +0300 Subject: [PATCH 04/14] Adding LRZ scripts --- .github/workflows/ci_cd_test.yml | 33 ++++++++++++++++++++++++- .lrz_scripts/debian.yml | 41 ++++++++++++++++++++++++++++++++ .lrz_scripts/openrc.sh | 37 ++++++++++++++++++++++++++++ 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 .lrz_scripts/debian.yml create mode 100644 .lrz_scripts/openrc.sh diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index 6dc58d3..d7e75e8 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -85,7 +85,7 @@ jobs: clean-run: - needs: build-n-publish + # needs: build-n-publish runs-on: ubuntu-latest strategy: matrix: @@ -111,3 +111,34 @@ jobs: - name: Run tests run: | pytest -v --import-mode=importlib + + lrz-benchmarks: + needs: build-n-publish + runs-on: ubuntu-latest + + steps: + - name: Start VM + env: + LRZ_PROJECT_ID: ${{ secrets.lrz_project_id }} + LRZ_USERNAME: ${{ secrets.lrz_username }} + LRZ_PASSWORD: ${{ secrets.lrz_password }} + run: | + source .lrz_script/openrc.sh + openstack stack create -t .lrz_script/debian.yml github-stack --wait + openstack stack output show -f value github-stack public_ip + export PUBLIC_IP=$(openstack stack output show -f value github-stack public_ip | tail -n 1) + echo "Public IP is ${PUBLIC_IP}" + + - name: Execute via ssh + uses: appleboy/ssh-action@master + with: + host: ${{ env.PUBLIC_IP }} + username: debian + key: ${{ secrets.lrz_ssh_key }} + script_stop: true + script: | + whoami + pwd + + - name: Stop VM + run: openstack stack delete github-stack --wait diff --git a/.lrz_scripts/debian.yml b/.lrz_scripts/debian.yml new file mode 100644 index 0000000..72fdced --- /dev/null +++ b/.lrz_scripts/debian.yml @@ -0,0 +1,41 @@ +heat_template_version: queens +description: Launch a server + +resources: + volume: + type: OS::Cinder::Volume + properties: + name: github_volume + image: Debian-10-buster + size: 20 + + server: + type: OS::Nova::Server + depends_on: volume + properties: + name: github_server + flavor: lrz.small + key_name: github + block_device_mapping_v2: + - volume_id: { get_resource: volume } + networks: + - network: internet + + floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network: { list_join: ['', [internet, '_pool']] } + + floating_ip_association: + type: OS::Neutron::FloatingIPAssociation + depends_on: + - server + - floating_ip + properties: + floatingip_id: { get_resource: floating_ip } + port_id: { get_attr: [server, addresses, internet, 0, port] } + +outputs: + public_ip: + description: The public ip of the server + value: { get_attr: [floating_ip, floating_ip_address] } diff --git a/.lrz_scripts/openrc.sh b/.lrz_scripts/openrc.sh new file mode 100644 index 0000000..242e25f --- /dev/null +++ b/.lrz_scripts/openrc.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# To use an OpenStack cloud you need to authenticate against the Identity +# service named keystone, which returns a **Token** and **Service Catalog**. +# The catalog contains the endpoints for all services the user/tenant has +# access to - such as Compute, Image Service, Identity, Object Storage, Block +# Storage, and Networking (code-named nova, glance, keystone, swift, +# cinder, and neutron). +# +# *NOTE*: Using the 3 *Identity API* does not necessarily mean any other +# OpenStack API is version 3. For example, your cloud provider may implement +# Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is +# only for the Identity API served through keystone. +export OS_AUTH_URL=https://cc.lrz.de:5000/v3 +# With the addition of Keystone we have standardized on the term **project** +# as the entity that owns the resources. +export OS_PROJECT_ID=$LRZ_PROJECT_ID +export OS_PROJECT_NAME="$LRZ_USERNAME" +export OS_USER_DOMAIN_NAME="ADS" +if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi +export OS_PROJECT_DOMAIN_ID="b6807b306c054287bec94113d22e9075" +if [ -z "$OS_PROJECT_DOMAIN_ID" ]; then unset OS_PROJECT_DOMAIN_ID; fi +# unset v2.0 items in case set +unset OS_TENANT_ID +unset OS_TENANT_NAME +# In addition to the owning entity (tenant), OpenStack stores the entity +# performing the action as the **user**. +export OS_USERNAME="$LRZ_USERNAME" +# With Keystone you pass the keystone password. +echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as user $OS_USERNAME: " +export OS_PASSWORD="$LRZ_PASSWORD" +# If your configuration has multiple regions, we set that information here. +# OS_REGION_NAME is optional and only valid in certain environments. +export OS_REGION_NAME="RegionOne" +# Don't leave a blank variable, unset it if it was empty +if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi +export OS_INTERFACE=public +export OS_IDENTITY_API_VERSION=3 From 0aaec51482cb86b28ed1909bb1e499f7382b79b5 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 16:04:55 +0300 Subject: [PATCH 05/14] Fix typo --- .github/workflows/ci_cd_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index d7e75e8..f11d08e 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -85,7 +85,7 @@ jobs: clean-run: - # needs: build-n-publish + needs: build-n-publish runs-on: ubuntu-latest strategy: matrix: @@ -113,7 +113,7 @@ jobs: pytest -v --import-mode=importlib lrz-benchmarks: - needs: build-n-publish + # needs: build-n-publish runs-on: ubuntu-latest steps: From 7f8bc00b323dbc5a6b3f7c43cf0126fef7e95a40 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 16:07:48 +0300 Subject: [PATCH 06/14] Fixing indentation --- .github/workflows/ci_cd_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index f11d08e..5c351cb 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -129,7 +129,7 @@ jobs: export PUBLIC_IP=$(openstack stack output show -f value github-stack public_ip | tail -n 1) echo "Public IP is ${PUBLIC_IP}" - - name: Execute via ssh + - name: Execute via ssh uses: appleboy/ssh-action@master with: host: ${{ env.PUBLIC_IP }} From c70d3da80620b7d5198a268c5d0626af5d889471 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 16:15:24 +0300 Subject: [PATCH 07/14] Adding checkout --- .github/workflows/ci_cd_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index 5c351cb..f00a2ee 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -117,6 +117,8 @@ jobs: runs-on: ubuntu-latest steps: + - uses: actions/checkout@v2 + - name: Start VM env: LRZ_PROJECT_ID: ${{ secrets.lrz_project_id }} From 68bc813a1f810ae11fb49bb5278a10d036e07fa8 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 16:17:38 +0300 Subject: [PATCH 08/14] Fix typo --- .github/workflows/ci_cd_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index f00a2ee..95be3ac 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -125,7 +125,7 @@ jobs: LRZ_USERNAME: ${{ secrets.lrz_username }} LRZ_PASSWORD: ${{ secrets.lrz_password }} run: | - source .lrz_script/openrc.sh + source .lrz_scripts/openrc.sh openstack stack create -t .lrz_script/debian.yml github-stack --wait openstack stack output show -f value github-stack public_ip export PUBLIC_IP=$(openstack stack output show -f value github-stack public_ip | tail -n 1) From cb8a18e8c0d999abc999ad0e0ebde7415e006f4b Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 16:22:00 +0300 Subject: [PATCH 09/14] Adding dependencies --- .github/workflows/ci_cd_test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index 95be3ac..d151ac8 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -119,6 +119,10 @@ jobs: steps: - uses: actions/checkout@v2 + - name: Install dependencies + run: | + sudo apt-get install python3-openstackclient python3-heatclient + - name: Start VM env: LRZ_PROJECT_ID: ${{ secrets.lrz_project_id }} From 818d15989c4dd16632589fa4c7628e3b3ca5b8b1 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 17:05:36 +0300 Subject: [PATCH 10/14] Still typos --- .github/workflows/ci_cd_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index d151ac8..9608e9b 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -130,7 +130,7 @@ jobs: LRZ_PASSWORD: ${{ secrets.lrz_password }} run: | source .lrz_scripts/openrc.sh - openstack stack create -t .lrz_script/debian.yml github-stack --wait + openstack stack create -t .lrz_scripts/debian.yml github-stack --wait openstack stack output show -f value github-stack public_ip export PUBLIC_IP=$(openstack stack output show -f value github-stack public_ip | tail -n 1) echo "Public IP is ${PUBLIC_IP}" From 45e2d9ba5996a96fdfa81efce6f88e1fcd489e97 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 17:18:38 +0300 Subject: [PATCH 11/14] More fixes --- .github/workflows/ci_cd_test.yml | 4 +++- .lrz_scripts/openrc.sh | 1 - setup.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index 9608e9b..f3acafd 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -132,7 +132,8 @@ jobs: source .lrz_scripts/openrc.sh openstack stack create -t .lrz_scripts/debian.yml github-stack --wait openstack stack output show -f value github-stack public_ip - export PUBLIC_IP=$(openstack stack output show -f value github-stack public_ip | tail -n 1) + PUBLIC_IP=$(openstack stack output show -f value github-stack public_ip | tail -n 1) + echo "public_ip=${PUBLIC_IP}" >> $GITHUB_ENV echo "Public IP is ${PUBLIC_IP}" - name: Execute via ssh @@ -147,4 +148,5 @@ jobs: pwd - name: Stop VM + if: ${{ always() }} run: openstack stack delete github-stack --wait diff --git a/.lrz_scripts/openrc.sh b/.lrz_scripts/openrc.sh index 242e25f..43bae56 100644 --- a/.lrz_scripts/openrc.sh +++ b/.lrz_scripts/openrc.sh @@ -26,7 +26,6 @@ unset OS_TENANT_NAME # performing the action as the **user**. export OS_USERNAME="$LRZ_USERNAME" # With Keystone you pass the keystone password. -echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as user $OS_USERNAME: " export OS_PASSWORD="$LRZ_PASSWORD" # If your configuration has multiple regions, we set that information here. # OS_REGION_NAME is optional and only valid in certain environments. diff --git a/setup.py b/setup.py index c9b32ab..9a1136f 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ "lyncs-cppyy", "lyncs-utils", "lyncs-clime", - "lyncs-setuptool", + "lyncs-setuptools", ], extras_require={ "test": ["pytest", "pytest-cov", "pytest-benchmark"], From 89020cede3d11d3185d4fa45d3ead4da703a856f Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 17:32:48 +0300 Subject: [PATCH 12/14] More more fixes --- .github/workflows/ci_cd_test.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index f3acafd..16b44f2 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -124,6 +124,7 @@ jobs: sudo apt-get install python3-openstackclient python3-heatclient - name: Start VM + id: start-vm env: LRZ_PROJECT_ID: ${{ secrets.lrz_project_id }} LRZ_USERNAME: ${{ secrets.lrz_username }} @@ -133,13 +134,13 @@ jobs: openstack stack create -t .lrz_scripts/debian.yml github-stack --wait openstack stack output show -f value github-stack public_ip PUBLIC_IP=$(openstack stack output show -f value github-stack public_ip | tail -n 1) - echo "public_ip=${PUBLIC_IP}" >> $GITHUB_ENV + echo "::set-output name=public-ip::${PUBLIC_IP}" echo "Public IP is ${PUBLIC_IP}" - name: Execute via ssh uses: appleboy/ssh-action@master with: - host: ${{ env.PUBLIC_IP }} + host: ${{ steps.start-vm.outputs.public-ip }} username: debian key: ${{ secrets.lrz_ssh_key }} script_stop: true @@ -149,4 +150,9 @@ jobs: - name: Stop VM if: ${{ always() }} - run: openstack stack delete github-stack --wait + LRZ_PROJECT_ID: ${{ secrets.lrz_project_id }} + LRZ_USERNAME: ${{ secrets.lrz_username }} + LRZ_PASSWORD: ${{ secrets.lrz_password }} + run: | + source .lrz_scripts/openrc.sh + openstack stack delete github-stack --wait -y From 7b4e7f965f15fce9da424aa9697299d95bbec7ef Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 17:33:48 +0300 Subject: [PATCH 13/14] Hope nobody will check this mess --- .github/workflows/ci_cd_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index 16b44f2..ff2b942 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -150,6 +150,7 @@ jobs: - name: Stop VM if: ${{ always() }} + env: LRZ_PROJECT_ID: ${{ secrets.lrz_project_id }} LRZ_USERNAME: ${{ secrets.lrz_username }} LRZ_PASSWORD: ${{ secrets.lrz_password }} From 30a3a8a8624014d2b772fab4d8825b29d4ab5b52 Mon Sep 17 00:00:00 2001 From: Simone Bacchio Date: Tue, 6 Oct 2020 17:51:35 +0300 Subject: [PATCH 14/14] Increasing timeout --- .github/workflows/ci_cd_test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci_cd_test.yml b/.github/workflows/ci_cd_test.yml index ff2b942..c08f20f 100644 --- a/.github/workflows/ci_cd_test.yml +++ b/.github/workflows/ci_cd_test.yml @@ -144,9 +144,12 @@ jobs: username: debian key: ${{ secrets.lrz_ssh_key }} script_stop: true + timeout: 1m + debug: true script: | whoami pwd + ls -al - name: Stop VM if: ${{ always() }}