mirror of https://github.com/Nonannet/copapy.git
upd2
This commit is contained in:
parent
997e797689
commit
6810c9dd0a
|
|
@ -19,8 +19,7 @@ jobs:
|
||||||
gcc-12-aarch64-linux-gnu \
|
gcc-12-aarch64-linux-gnu \
|
||||||
gcc-12-arm-linux-gnueabihf \
|
gcc-12-arm-linux-gnueabihf \
|
||||||
gcc-12-mips-linux-gnu \
|
gcc-12-mips-linux-gnu \
|
||||||
gcc-12-riscv64-linux-gnu \
|
gcc-12-riscv64-linux-gnu
|
||||||
mingw-w64
|
|
||||||
|
|
||||||
- name: Build object files
|
- name: Build object files
|
||||||
run: bash src/copapy/obj/crosscompile.sh
|
run: bash src/copapy/obj/crosscompile.sh
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,21 @@ on:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
build_stencils:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Build object files
|
||||||
|
run: bash src/copapy/obj/crosscompile.sh
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: stencil-object-files
|
||||||
|
path: src/copapy/obj/*.o
|
||||||
|
|
||||||
build-ubuntu:
|
build-ubuntu:
|
||||||
|
needs: [build_stencils]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
|
|
@ -18,15 +32,16 @@ jobs:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: stencil-object-files
|
||||||
|
path: src/copapy/obj
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
- name: Build ops obj files
|
|
||||||
run: |
|
|
||||||
bash src/copapy/obj/nativecompile.sh
|
|
||||||
|
|
||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
run: python -m pip install -e .[dev]
|
run: python -m pip install -e .[dev]
|
||||||
|
|
||||||
|
|
@ -44,12 +59,6 @@ jobs:
|
||||||
#- name: Lint code with flake8
|
#- name: Lint code with flake8
|
||||||
# run: flake8
|
# run: flake8
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
if: strategy.job-index == 0
|
|
||||||
with:
|
|
||||||
name: stencil-object-files-linux
|
|
||||||
path: src/copapy/obj/*.o
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
if: strategy.job-index == 0
|
if: strategy.job-index == 0
|
||||||
with:
|
with:
|
||||||
|
|
@ -57,6 +66,7 @@ jobs:
|
||||||
path: bin/*
|
path: bin/*
|
||||||
|
|
||||||
build-windows:
|
build-windows:
|
||||||
|
needs: [build_stencils]
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
|
|
@ -67,6 +77,11 @@ jobs:
|
||||||
- name: Check out code
|
- name: Check out code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/download-artifact@v4
|
||||||
|
with:
|
||||||
|
name: stencil-object-files
|
||||||
|
path: src/copapy/obj
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
|
|
@ -100,12 +115,6 @@ jobs:
|
||||||
#- name: Lint code with flake8
|
#- name: Lint code with flake8
|
||||||
# run: flake8
|
# run: flake8
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
if: strategy.job-index == 0
|
|
||||||
with:
|
|
||||||
name: stencil-object-files-win
|
|
||||||
path: src/copapy/obj/*.o
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
if: strategy.job-index == 0
|
if: strategy.job-index == 0
|
||||||
with:
|
with:
|
||||||
|
|
|
||||||
2
build.sh
2
build.sh
|
|
@ -1,9 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
set -v
|
set -v
|
||||||
python src/copapy/generate_stencils.py
|
|
||||||
SRC=src/copapy/stencils.c
|
SRC=src/copapy/stencils.c
|
||||||
DEST=src/copapy/obj
|
DEST=src/copapy/obj
|
||||||
|
python src/copapy/generate_stencils.py $SRC
|
||||||
mkdir -p $DEST
|
mkdir -p $DEST
|
||||||
gcc -c $SRC -O0 -o $DEST/stencils_x86_64_O0.o
|
gcc -c $SRC -O0 -o $DEST/stencils_x86_64_O0.o
|
||||||
gcc -c $SRC -O1 -o $DEST/stencils_x86_64_O1.o
|
gcc -c $SRC -O1 -o $DEST/stencils_x86_64_O1.o
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,29 @@
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
op_signs = {'add': '+', 'sub': '-', 'mul': '*', 'div': '/',
|
op_signs = {'add': '+', 'sub': '-', 'mul': '*', 'div': '/',
|
||||||
'gt': '>', 'eq': '==', 'mod': '%'}
|
'gt': '>', 'eq': '==', 'mod': '%'}
|
||||||
|
|
||||||
|
func_prefix = '' # __attribute__((ms_abi))
|
||||||
|
|
||||||
def get_function_start() -> str:
|
def get_function_start() -> str:
|
||||||
return """
|
return f"""
|
||||||
int function_start(){
|
{func_prefix}int function_start(){{
|
||||||
result_int(0); // dummy call instruction before marker gets striped
|
result_int(0); // dummy call instruction before marker gets striped
|
||||||
asm volatile (".long 0xE2401F0F");
|
asm volatile (".long 0xE2401F0F");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def get_function_end() -> str:
|
def get_function_end() -> str:
|
||||||
return """
|
return f"""
|
||||||
int function_end(){
|
{func_prefix}int function_end(){{
|
||||||
result_int(0);
|
result_int(0);
|
||||||
asm volatile (".long 0xE1401F0F");
|
asm volatile (".long 0xE1401F0F");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -109,6 +111,14 @@ def permutate(*lists: list[str]) -> Generator[list[str], None, None]:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("path", type=str, help="Output file path")
|
||||||
|
parser.add_argument("--abi", type=str, default="", help="Optionaler String (Standard: '')")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if args.abi:
|
||||||
|
func_prefix = f"__attribute__(({args.abi}_abi)) "
|
||||||
|
|
||||||
types = ['int', 'float']
|
types = ['int', 'float']
|
||||||
ops = ['add', 'sub', 'mul', 'div', 'gt', 'eq']
|
ops = ['add', 'sub', 'mul', 'div', 'gt', 'eq']
|
||||||
|
|
||||||
|
|
@ -146,5 +156,5 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
code += get_function_start() + get_function_end()
|
code += get_function_start() + get_function_end()
|
||||||
|
|
||||||
with open('src/copapy/stencils.c', 'w') as f:
|
with open(args.path, 'w') as f:
|
||||||
f.write(code)
|
f.write(code)
|
||||||
|
|
|
||||||
|
|
@ -12,20 +12,21 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -v
|
set -v
|
||||||
python src/copapy/generate_stencils.py
|
|
||||||
SRC=src/copapy/stencils.c
|
SRC=src/copapy/stencils.c
|
||||||
DEST=src/copapy/obj
|
DEST=src/copapy/obj
|
||||||
OPT=O3
|
OPT=O3
|
||||||
|
|
||||||
mkdir -p $DEST
|
mkdir -p $DEST
|
||||||
|
|
||||||
x86_64-w64-mingw32-gcc --version
|
# Windows x86_64 (ARM64)
|
||||||
|
python src/copapy/generate_stencils.py --abi ms $SRC
|
||||||
|
gcc-12 -$OPT -c $SRC -o $DEST/stencils_AMD64_$OPT.o
|
||||||
|
|
||||||
# Native x86_64
|
# Native x86_64
|
||||||
|
python src/copapy/generate_stencils.py $SRC
|
||||||
gcc-12 -$OPT -c $SRC -o $DEST/stencils_x86_64_$OPT.o
|
gcc-12 -$OPT -c $SRC -o $DEST/stencils_x86_64_$OPT.o
|
||||||
|
|
||||||
# Windows x86_64 (ARM64)
|
|
||||||
mingw-w64 -$OPT -c $SRC -o $DEST/stencils_AMD64_$OPT.o
|
|
||||||
|
|
||||||
# ARM64
|
# ARM64
|
||||||
aarch64-linux-gnu-gcc-12 -$OPT -c $SRC -o $DEST/stencils_aarch64_$OPT.o
|
aarch64-linux-gnu-gcc-12 -$OPT -c $SRC -o $DEST/stencils_aarch64_$OPT.o
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,17 @@ set -v
|
||||||
SRC=src/copapy/stencils.c
|
SRC=src/copapy/stencils.c
|
||||||
DEST=src/copapy/obj
|
DEST=src/copapy/obj
|
||||||
|
|
||||||
python src/copapy/generate_stencils.py
|
python src/copapy/generate_stencils.py $SRC
|
||||||
|
|
||||||
mkdir -p $DEST
|
mkdir -p $DEST
|
||||||
gcc-12 -c $SRC -O0 -o $DEST/stencils_x86_64_O0.o
|
gcc-12 -c $SRC -O0 -o $DEST/stencils_x86_64_O0.o
|
||||||
gcc-12 -c $SRC -O1 -o $DEST/stencils_x86_64_O1.o
|
gcc-12 -c $SRC -O1 -o $DEST/stencils_x86_64_O1.o
|
||||||
gcc-12 -c $SRC -O2 -o $DEST/stencils_x86_64_O2.o
|
gcc-12 -c $SRC -O2 -o $DEST/stencils_x86_64_O2.o
|
||||||
gcc-12 -c $SRC -O3 -o $DEST/stencils_x86_64_O3.o
|
gcc-12 -c $SRC -O3 -o $DEST/stencils_x86_64_O3.o
|
||||||
|
|
||||||
|
python src/copapy/generate_stencils.py --abi ms $SRC
|
||||||
|
|
||||||
|
gcc-12 -c $SRC -O0 -o $DEST/stencils_AMD64_O0.o
|
||||||
|
gcc-12 -c $SRC -O1 -o $DEST/stencils_AMD64_O1.o
|
||||||
|
gcc-12 -c $SRC -O2 -o $DEST/stencils_AMD64_O2.o
|
||||||
|
gcc-12 -c $SRC -O3 -o $DEST/stencils_AMD64_O3.o
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
set -e
|
|
||||||
set -v
|
|
||||||
|
|
||||||
SRC=src/copapy/stencils.c
|
|
||||||
DEST=src/copapy/obj
|
|
||||||
|
|
||||||
python src/copapy/generate_stencils.py
|
|
||||||
|
|
||||||
mkdir -p $DEST
|
|
||||||
x86_64-w64-mingw32-gcc -c $SRC -O0 -o $DEST/stencils_AMD64_O0.o
|
|
||||||
x86_64-w64-mingw32-gcc -c $SRC -O1 -o $DEST/stencils_AMD64_O1.o
|
|
||||||
x86_64-w64-mingw32-gcc -c $SRC -O2 -o $DEST/stencils_AMD64_O2.o
|
|
||||||
x86_64-w64-mingw32-gcc -c $SRC -O3 -o $DEST/stencils_AMD64_O3.o
|
|
||||||
|
|
||||||
x86_64-w64-mingw32-gcc --version
|
|
||||||
Loading…
Reference in New Issue