CSL backend: integer constant in a vector op is emitted as a float, and cslc rejects it

Open
#83 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
compilers

Research direction

Start by reproducing the issue with the provided kernel and command, then inspect the compiler path that emits the shown @add16 call and trace how the integer literal becomes 1.0. Done means generated CSL passes the integer constant with the expected type and cslc accepts the output. The payload names no source files or tests, so locate the relevant emission code and add or run a regression check there.

Written by the indexing model from the issue text.

Description

Repro (upstream main @ 984975f, cbcore SDK 202505230211):

kernel @int_const_add<N>(stream<i16, N>[1, 1] readonly a_in, stream<i16, N>[1, 1] writeonly out) {
    place i16 i, i16 j in [0, 0] {
        i16[N] a
    }
    compute i16 i, i16 j in [0, 0] {
        await receive(a, a_in[i, j])
        await map i16 k in [0:N] {
            a[k] = a[k] + 1
        }
        await send(a, out[i, j])
    }
}

Commands:
sptlc int_const_add.sptl out_csl --param N=4

Expected:

The generated code_0_0.csl contains @add16(a_in_dsd, a_in_dsd, 1.0); and cslc fails:

code_0_0.csl:22:5: error: operand types do not match expectations
    @add16(a_in_dsd, a_in_dsd, 1.0);
code_0_0.csl:22:5: note: got type(s): mem1d_dsd, mem1d_dsd, comptime_float
code_0_0.csl:22:5: note:     expected type(s): DSD/DSR, DSD/DSR, i16

LOG: Generated CSL


param memcpy_params;
const sys_mod = @import_module("<memcpy/memcpy>", memcpy_params);
// Benchmarking counters
const timestamp = @import_module("<time>");
// Place block
var a_in: [4]i16;
var out: [4]i16;
var __benchmark_start: [3]u16;
var __benchmark_stop: [3]u16;
var __a_in_ptr: [*]i16 = &a_in;
var __out_ptr: [*]i16 = &out;
var ____benchmark_start_ptr: [*]u16 = &__benchmark_start;
var ____benchmark_stop_ptr: [*]u16 = &__benchmark_stop;

// DSDs
const a_in_dsd = @get_dsd(mem1d_dsd, .{ .tensor_access = |__index|{4} -> a_in[__index] });
const out_dsd = @get_dsd(mem1d_dsd, .{ .tensor_access = |__index|{4} -> out[__index] });

const task_0_id = @get_local_task_id(8);
task task_slot_0() void {
    @add16(a_in_dsd, a_in_dsd, 1.0);
    @mov16(out_dsd, a_in_dsd);
    timestamp.get_timestamp(&__benchmark_stop);
    timestamp.disable_tsc();
    sys_mod.unblock_cmd_stream();
}

fn int_const_add() void {
    timestamp.enable_tsc();
    timestamp.get_timestamp(&__benchmark_start);
    @activate(task_0_id);
}

comptime {
    @export_symbol(__a_in_ptr, "a_in");
    @export_symbol(__out_ptr, "out");
    @export_symbol(____benchmark_start_ptr, "__benchmark_start");
    @export_symbol(____benchmark_stop_ptr, "__benchmark_stop");
    @bind_local_task(task_slot_0, task_0_id);

    @export_symbol(int_const_add, "int_const_add");
}
Dominant language
Python
Stars
12
Forks
2
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spcl/spada

All issues in spcl/spada

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.