Skip to content

Commit

Permalink
bigint 사용/사용안함 타겟 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Apr 5, 2024
1 parent 3348ae1 commit ea40031
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 20 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 25 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
```
git clone https://github.com/aheui/rpaheui
make # RPYTHON 환경변수 설정 필요. rpython은 pypy 소스코드를 내려받으면 포함되어 있습니다. 버전은 github actions 설정을 참고해 주세요.
./aheui-c <your-aheui-code>
./bin/aheui-c <아희 코드 파일>
./bin/aheui-bigint-c <큰 정수가 필요한 아희 코드 파일>
```

JIT로 속도 올리기
Expand Down
3 changes: 1 addition & 2 deletions aheui/aheui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion aheui/int/bigint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
from rpython.rlib.rbigint import rbigint


NAME = 'bigint'


Int = rbigint


Expand Down Expand Up @@ -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
3 changes: 3 additions & 0 deletions aheui/int/smallint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
from aheui._compat import _bytestr


NAME = 'smallint'


Int = int


Expand Down
4 changes: 2 additions & 2 deletions aheui/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion aheui/warning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.'),
Expand Down

0 comments on commit ea40031

Please sign in to comment.