Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Size in new[] explicitly casted to size_t #1775

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions dace/codegen/instrumentation/data/data_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _generate_copy_to_host(self, node: nodes.AccessNode, desc: dt.Array, ptr: st
# Emit synchronous memcpy
preamble = f'''
{{
{new_desc.as_arg(name=new_ptr)} = new {desc.dtype.ctype}[{csize}];
{new_desc.as_arg(name=new_ptr)} = new {desc.dtype.ctype}[std::size_t({csize})];
{self.backend}Memcpy({new_ptr}, {ptr}, sizeof({desc.dtype.ctype}) * ({csize}), {self.backend}MemcpyDeviceToHost);
'''

Expand All @@ -65,7 +65,7 @@ def _generate_copy_to_device(self, node: nodes.AccessNode, desc: dt.Array, ptr:
# Emit synchronous memcpy
preamble = f'''
{{
{new_desc.as_arg(name=new_ptr)} = new {desc.dtype.ctype}[{csize}];
{new_desc.as_arg(name=new_ptr)} = new {desc.dtype.ctype}[std::size_t({csize})];
'''

postamble = f'''
Expand Down
4 changes: 2 additions & 2 deletions dace/codegen/targets/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def allocate_array(self, sdfg: SDFG, cfg: ControlFlowRegion, dfg: StateSubgraphV
if not declared:
declaration_stream.write(f'{nodedesc.dtype.ctype} *{name};\n', cfg, state_id, node)
allocation_stream.write(
"%s = new %s DACE_ALIGN(64)[%s];\n" % (alloc_name, nodedesc.dtype.ctype, cpp.sym2cpp(arrsize)), cfg,
"%s = new %s DACE_ALIGN(64)[std::size_t(%s)];\n" % (alloc_name, nodedesc.dtype.ctype, cpp.sym2cpp(arrsize)), cfg,
state_id, node)
define_var(name, DefinedType.Pointer, ctypedef)

Expand Down Expand Up @@ -548,7 +548,7 @@ def allocate_array(self, sdfg: SDFG, cfg: ControlFlowRegion, dfg: StateSubgraphV
"""
#pragma omp parallel
{{
{name} = new {ctype} DACE_ALIGN(64)[{arrsize}];""".format(ctype=nodedesc.dtype.ctype,
{name} = new {ctype} DACE_ALIGN(64)[std::size_t({arrsize})];""".format(ctype=nodedesc.dtype.ctype,
name=alloc_name,
arrsize=cpp.sym2cpp(arrsize)),
cfg,
Expand Down
3 changes: 2 additions & 1 deletion dace/codegen/targets/snitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def allocate_array(self, sdfg: SDFG, cfg: ControlFlowRegion, dfg: StateSubgraphV
#pragma omp parallel
{{
#error "malloc is not threadsafe"
{name} = new {ctype} [{arrsize}];""".format(ctype=nodedesc.dtype.ctype,
{name} = new {ctype} [std::size_t({arrsize})];""".format(ctype=nodedesc.dtype.ctype,
name=alloc_name,
arrsize=cpp.sym2cpp(arrsize)),
cfg,
Expand Down Expand Up @@ -1108,6 +1108,7 @@ def gen_code_snitch(sdfg):

# change new/delete to malloc/free
code._code = re.sub(r"new (.+) \[(\d*)\];", r"(\1*)malloc(\2*sizeof(\1));", code._code)
code._code = re.sub(r"new (.+) \[std::size_t\((\d*)\)\];", r"(\1*)malloc(\2*sizeof(\1));", code._code)
code._code = re.sub(r"new ([a-zA-Z0-9 _]*);", r"(\1*)malloc(sizeof(\1));", code._code)
code._code = re.sub(r"delete (.*);", r"free(\1);", code._code)
code._code = re.sub(r"delete\[\] (.*);", r"free(\1);", code._code)
Expand Down
2 changes: 0 additions & 2 deletions tests/npbench/misc/stockham_fft_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,10 @@ def run_stockham_fft(device_type: dace.dtypes.DeviceType):
return sdfg


@pytest.mark.skip(reason="Assertion error in read_and_write_sets")
def test_cpu():
run_stockham_fft(dace.dtypes.DeviceType.CPU)


@pytest.mark.skip(reason="Assertion error in read_and_write_sets")
@pytest.mark.gpu
def test_gpu():
run_stockham_fft(dace.dtypes.DeviceType.GPU)
Expand Down
Loading