From ea40031fd78693eb6d2f59ca53703939b3479007 Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Fri, 5 Apr 2024 03:25:47 +0900 Subject: [PATCH] =?UTF-8?q?bigint=20=EC=82=AC=EC=9A=A9/=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=EC=95=88=ED=95=A8=20=ED=83=80=EA=B2=9F=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yaml | 5 +++-- Makefile | 36 +++++++++++++++++++++++++----------- README.md | 3 ++- aheui/aheui.py | 3 +-- aheui/int/bigint.py | 6 +++++- aheui/int/smallint.py | 3 +++ aheui/option.py | 4 ++-- aheui/warning.py | 2 +- 8 files changed, 42 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 47c696d..a1ef5dc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -60,8 +60,9 @@ jobs: run: | export RPYTHON="pypy $GITHUB_WORKSPACE/pypy/rpython/bin/rpython" cd $GITHUB_WORKSPACE - make + make -j 3 - name: Test with snippets run: | cd "$GITHUB_WORKSPACE/snippets" - AHEUI="$GITHUB_WORKSPACE/rpaheui-c" ./test.sh --disable logo integer + AHEUI="$GITHUB_WORKSPACE/rpaheui-c" ./test.sh --disable integer + AHEUI="$GITHUB_WORKSPACE/rpaheui-bigint-c" ./test.sh \ No newline at end of file diff --git a/Makefile b/Makefile index 5dbb95d..363cd00 100644 --- a/Makefile +++ b/Makefile @@ -3,30 +3,44 @@ RPYTHON?=../pypy/rpython/bin/rpython RPYTHONFLAGS?=--opt=jit --translation-jit_opencoder_model=big -all: aheui-c aheui-py +.PHONY: all rpaheui-c rpaheui-bigint-c test-bigint test-smallint test-py clean install + + +all: aheui-bigint-c aheui-c aheui-py version: echo "VERSION = '`git describe --tags`'" > aheui/version.py -aheui-py: +aheui-py: version cp rpaheui.py bin/aheui-py cp rpaheui.py bin/aheui -aheui-c: version +rpaheui-bigint-c: + RPAHEUI_BIGINT=1 $(RPYTHON) $(RPYTHONFLAGS) --output rpaheui-bigint-c rpaheui.py + +rpaheui-c: $(RPYTHON) $(RPYTHONFLAGS) rpaheui.py +aheui-bigint-c: rpaheui-bigint-c + cp rpaheui-bigint-c bin/aheui-bigint-c + +aheui-c: rpaheui-c + cp rpaheui-c bin/aheui-c + clean: - rm rpaheui-c + rm rpaheui-smallint rpaheui-bigint -install: aheui-c +install: rpaheui-c rpaheui-bigint-c + cp rpaheui-bigint-c /usr/local/bin/rpaheui-bigint cp rpaheui-c /usr/local/bin/rpaheui ln -s /usr/local/bin/rpaheui /usr/local/bin/aheui -test: - if [ -e snippets ]; then cd snippets && git pull; else git clone https://github.com/aheui/snippets; fi - cd snippets && AHEUI="../rpaheui-c" bash test.sh +test-bigint: + cd snippets && AHEUI="../rpaheui-bigint-c" bash test.sh + +test-smallint: + cd snippets && AHEUI="../rpaheui-c" bash test.sh --disable integer -testpy: +test-py: pytest - if [ -e snippets ]; then cd snippets && git pull; else git clone https://github.com/aheui/snippets; fi - cd snippets && AHEUI=../rpaheui.py bash test.sh + cd snippets && AHEUI=../bin/aheui bash test.sh --disable logo diff --git a/README.md b/README.md index a6fd413..cd32fab 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ ``` git clone https://github.com/aheui/rpaheui make # RPYTHON 환경변수 설정 필요. rpython은 pypy 소스코드를 내려받으면 포함되어 있습니다. 버전은 github actions 설정을 참고해 주세요. -./aheui-c +./bin/aheui-c <아희 코드 파일> +./bin/aheui-bigint-c <큰 정수가 필요한 아희 코드 파일> ``` JIT로 속도 올리기 diff --git a/aheui/aheui.py b/aheui/aheui.py index eb76b58..7bf46b3 100644 --- a/aheui/aheui.py +++ b/aheui/aheui.py @@ -440,7 +440,6 @@ def mainloop(program, debug): return 0 - def open_w(filename): return os.open(filename, os.O_WRONLY | os.O_CREAT, 0o644) @@ -482,7 +481,7 @@ def entry_point(argv): cmd, source, contents, str_opt_level, target, aheuic_output, comment_aheuis, output, warning_limit, trace_limit = process_options(argv, os.environ) except SystemExit: return 1 - + warnings.limit = warning_limit if trace_limit >= 0: jit.set_param(driver, 'trace_limit', trace_limit) diff --git a/aheui/int/bigint.py b/aheui/int/bigint.py index 09cbf0d..4744b8a 100644 --- a/aheui/int/bigint.py +++ b/aheui/int/bigint.py @@ -3,6 +3,9 @@ from rpython.rlib.rbigint import rbigint +NAME = 'bigint' + + Int = rbigint @@ -62,4 +65,5 @@ def ge(r1, r2): @jit.elidable def is_zero(r): - return r.sign == 0 + # return r.sign == 0 + return r._size == 0 # pypy 7.3.15 diff --git a/aheui/int/smallint.py b/aheui/int/smallint.py index 8376a4f..cbd09b6 100644 --- a/aheui/int/smallint.py +++ b/aheui/int/smallint.py @@ -7,6 +7,9 @@ from aheui._compat import _bytestr +NAME = 'smallint' + + Int = int diff --git a/aheui/option.py b/aheui/option.py index 3618458..c3860ab 100644 --- a/aheui/option.py +++ b/aheui/option.py @@ -4,6 +4,7 @@ import os from aheui._argparse import ArgumentParser +from aheui._compat import bigint from aheui.version import VERSION from aheui import compile @@ -32,11 +33,10 @@ parser.add_argument('--no-c', '--no-c', narg='0', default='no', description='Do not generate `.aheuic` file automatically.', full_description='\tWhat is .aheuic? https://github.com/aheui/snippets/commit/cbb5a12e7cd2db771538ab28dfbc9ad1ada86f35\n') parser.add_argument('--warning-limit', '--warning-limit', default='', description='Set repetitive warning limit. '' fallbacks to environment variable `RPAHEUI_WARNING_LIMIT`. 0 means no warning. -1 means no limit. Default is 3.') parser.add_argument('--trace-limit', '--trace-limit', default='', description='Set JIT trace limit. '' fallbacks to environment variable `RPAHEUI_TRACE_LIMIT`.') -parser.add_argument('--version', '-v', narg='-1', default='no', description='Show program version', message=VERSION) +parser.add_argument('--version', '-v', narg='-1', default='no', description='Show program version', message=('%s %s' % (VERSION, bigint.NAME)).encode('utf-8')) parser.add_argument('--help', '-h', narg='-1', default='no', description='Show this help text') - def kwarg_or_environ(kwargs, environ, arg_key, env_key): if arg_key in kwargs and kwargs[arg_key] != '': return (1, kwargs[arg_key]) diff --git a/aheui/warning.py b/aheui/warning.py index 9354159..cfe044c 100644 --- a/aheui/warning.py +++ b/aheui/warning.py @@ -11,7 +11,7 @@ def __init__(self, name, message): def format(self, *args): return self.message % args - + WARNING_LIST = [ Warning(b'write-utf8-range', b'[Warning:UndefinedBehavior:write-utf8-range] value %x is out of unicode codepoint range.'),