Skip to content

Commit

Permalink
Merge branch 'HigherOrderCO:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
sepcnt authored May 21, 2024
2 parents 8f15382 + b86616f commit 3b6404d
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 142 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ tmp/
examples/**/main
examples/**/*.c
examples/**/*.cu
.out.hvm
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[package]
name = "hvm"
version = "2.0.12"
version = "2.0.13"
edition = "2021"
build = "build.rs"
description = "A massively parallel, optimal functional runtime in Rust."
license = "Apache-2.0"

[lib]
name = "hvm"
path = "src/lib.rs"

[dependencies]
TSPL = "0.0.12"
clap = "4.5.2"
Expand Down
125 changes: 0 additions & 125 deletions POST.md

This file was deleted.

4 changes: 2 additions & 2 deletions examples/sort_bitonic/main.bend
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def swap(s, a, b):
def warp(d, s, a, b):
switch d:
case 0:
return swap(s + (a > b), a, b)
return swap(s ^ (a > b), a, b)
case _:
(a.a,a.b) = a
(b.a,b.b) = b
Expand Down Expand Up @@ -56,4 +56,4 @@ def sort(d, s, t):
return flow(d, s, (sort(d-1, 0, t.a), sort(d-1, 1, t.b)))

def main:
return sum(18, sort(18, 0, gen(18, 0)))
return sum(20, sort(20, 0, gen(20, 0)))
8 changes: 4 additions & 4 deletions examples/sort_bitonic/main.hvm
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
&! @gen ~ (d (e f))

@main = a
& @sum ~ (18 (@main__C1 a))
& @sum ~ (20 (@main__C1 a))

@main__C0 = a
& @gen ~ (18 (0 a))
& @gen ~ (20 (0 a))

@main__C1 = a
& @sort ~ (18 (0 (@main__C0 a)))
& @sort ~ (20 (0 (@main__C0 a)))

@sort = (?(((a (* a)) @sort__C0) (b (c d))) (c (b d)))

Expand All @@ -46,7 +46,7 @@

@warp = (?((@warp__C0 @warp__C1) (a (b (c d)))) (c (b (a d))))

@warp__C0 = ({a e} ({$(:[>] $(a b)) d} ($(:[+] $(b c)) f)))
@warp__C0 = ({a e} ({$(:[>] $(a b)) d} ($(:[^] $(b c)) f)))
& @swap ~ (c (d (e f)))

@warp__C1 = ({a f} ((d i) ((c h) ({b g} ((e j) (k l))))))
Expand Down
4 changes: 2 additions & 2 deletions src/hvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,11 @@ static inline u32 get_u24(Numb word) {

// Constructor and getters for I24 (signed 24-bit integer)
static inline Numb new_i24(i32 val) {
return (((u32)val << 4) & 0xFFFFFF) | I24;
return (((u32)val & 0xFFFFFF) << 4) | I24;
}

static inline i32 get_i24(Numb word) {
return (((word >> 4) & 0xFFFFFF) << 8) >> 8;
return ((i32)((word >> 4) & 0xFFFFFF)) << 8 >> 8;
}

// Constructor and getters for F24 (24-bit float)
Expand Down
4 changes: 2 additions & 2 deletions src/hvm.cu
Original file line number Diff line number Diff line change
Expand Up @@ -694,11 +694,11 @@ __device__ __host__ inline u32 get_u24(Numb word) {

// Constructor and getters for I24 (signed 24-bit integer)
__device__ __host__ inline Numb new_i24(i32 val) {
return (((u32)val << 4) & 0xFFFFFF) | I24;
return (((u32)val & 0xFFFFFF) << 4) | I24;
}

__device__ __host__ inline i32 get_i24(Numb word) {
return (((word >> 4) & 0xFFFFFF) << 8) >> 8;
return ((i32)((word >> 4) & 0xFFFFFF)) << 8 >> 8;
}

// Constructor and getters for F24 (24-bit float)
Expand Down
2 changes: 1 addition & 1 deletion src/hvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ impl TMem {
// Attempts to directionally point `A ~> B`
loop {
// If `A` is NODE: swap `A` and `B`, and continue
if a.get_tag() != VAR && a.get_tag() == VAR {
if a.get_tag() != VAR && b.get_tag() == VAR {
let x = a; a = b; b = x;
}

Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod ast;
pub mod cmp;
pub mod hvm;
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
#![allow(unused_variables)]

use clap::{Arg, ArgAction, Command};
use ::hvm::{ast, cmp, hvm};
use std::fs;
use std::io::Write;
use std::path::PathBuf;
use std::process::Command as SysCommand;

mod ast;
mod cmp;
mod hvm;

#[cfg(feature = "c")]
extern "C" {
fn hvm_c(book_buffer: *const u32, run_io: bool);
Expand Down

0 comments on commit 3b6404d

Please sign in to comment.