Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions dace/codegen/codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,38 @@ def generate_code(sdfg: SDFG, validate=True) -> List[CodeObject]:
import filecmp
import shutil
import tempfile
with tempfile.TemporaryDirectory() as tmp_dir:
sdfg.save(f'{tmp_dir}/test.sdfg', hash=False)
sdfg2 = SDFG.from_file(f'{tmp_dir}/test.sdfg')
sdfg2.save(f'{tmp_dir}/test2.sdfg', hash=False)
import os
with tempfile.NamedTemporaryFile(suffix="_.sdfg", delete=False) as tmp1, \
tempfile.NamedTemporaryFile(suffix="_.sdfg", delete=False) as tmp2:
tmp1_path = tmp1.name
tmp2_path = tmp2.name

try:
sdfg.save(tmp1_path, hash=False)
sdfg2 = SDFG.from_file(tmp1_path)
sdfg2.save(tmp2_path, hash=False)

print('Testing SDFG serialization...')
if not filecmp.cmp(f'{tmp_dir}/test.sdfg', f'{tmp_dir}/test2.sdfg'):
with open(f'{tmp_dir}/test.sdfg', 'r') as f1:
with open(f'{tmp_dir}/test2.sdfg', 'r') as f2:
diff = difflib.unified_diff(f1.readlines(),
f2.readlines(),
fromfile='test.sdfg (first save)',
tofile='test2.sdfg (after roundtrip)')
if not filecmp.cmp(tmp1_path, tmp2_path):
with open(tmp1_path, 'r') as f1, open(tmp2_path, 'r') as f2:
diff = difflib.unified_diff(f1.readlines(),
f2.readlines(),
fromfile='test.sdfg (first save)',
tofile='test2.sdfg (after roundtrip)')
diff = ''.join(diff)
shutil.move(f'{tmp_dir}/test.sdfg', 'test.sdfg')
shutil.move(f'{tmp_dir}/test2.sdfg', 'test2.sdfg')

shutil.copy(tmp1_path, 'test.sdfg')
shutil.copy(tmp2_path, 'test2.sdfg')
raise RuntimeError(f'SDFG serialization failed - files do not match:\n{diff}')

finally:
# Clean up the temporary files
try:
os.remove(tmp1_path)
os.remove(tmp2_path)
except OSError:
pass

if config.Config.get_bool('optimizer', 'detect_control_flow'):
# NOTE: This should likely be done either earlier in the future, or changed entirely in modular codegen.
# It is being done here to ensure that for now the semantics of the setting are preserved and legacy tests,
Expand Down
4 changes: 2 additions & 2 deletions dace/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ required:
type: str
title: Arguments
description: Compiler argument flags
default: '-std=c++14 -fPIC -Wall -Wextra -O3 -march=native -ffast-math -Wno-unused-parameter -Wno-unused-label'
default: '-fopenmp -fPIC -Wall -Wextra -O3 -march=native -ffast-math -Wno-unused-parameter -Wno-unused-label'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why is this needed? We already run with OMP.. right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, my I have some config problem in my system, I forgot the flag... Consexpr flag should be default tho imho

default_Windows: '/O2 /fp:fast /arch:AVX2 /D_USRDLL /D_WINDLL /D__restrict__=__restrict'

libs:
Expand Down Expand Up @@ -303,7 +303,7 @@ required:
type: str
title: nvcc Arguments
description: Compiler argument flags for CUDA
default: '-Xcompiler -march=native --use_fast_math -Xcompiler -Wno-unused-parameter'
default: '--expt-relaxed-constexpr -Xcompiler -march=native --use_fast_math -Xcompiler -Wno-unused-parameter'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the issue when not passing this arg? A warning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually DaCe needs this flag to compile, because it uses constexpr functions in functions marked as host and device. nvidia compiler is graceful enough to compile it as long we don't really call those functions (it is rare).
I think this happens because unused headers are not necessarily need to be included and compilers optimize this out.

We get a lot of warnings about this everytime we compile GPU code.

About the openmp flag, I have some configuration problem,.openmp flag shouldn't be normally needed

default_Windows: '-O3 --use_fast_math'

hip_args:
Expand Down
3 changes: 3 additions & 0 deletions dace/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,9 @@ def isconstant(var):
string = stringtype()
MPI_Request = opaque('MPI_Request')

FLOAT_TYPES = {float64, float32, float16}
INT_TYPES = {int8, int16, int32, int64, uintp, uint8, uint16, uint32, uint64}


@undefined_safe_enum
@extensible_enum
Expand Down
Loading
Loading