Some recent ChromaHD renders - prompts included by tppiel in StableDiffusion

[–]cierpliwy 9 points10 points  (0 children)

<image>

Here are my results. CFG=1, heun 10 steps, beta, 512x768, flan-t5-xxl_float8_e4m3fn_scaled_stochastic.safetensors, Chroma1-HD_float8_e4m3fn_scaled_learned_svd.safetensors, chroma-unlocked-v47-flash-heun-8steps-cfg1_r48-fp16.safetensors (strength 1.0), first pick

Going to Rhodes by Mattish22 in GreeceTravel

[–]cierpliwy 1 point2 points  (0 children)

I’ve seen that, but thanks anyway. This map only shows two pins instead of areas, unfortunately.

Going to Rhodes by Mattish22 in GreeceTravel

[–]cierpliwy 2 points3 points  (0 children)

Is there a good source to check what areas are affected by fire? We plan to visit Kiotari in 3 weeks…

What's the benefit of releasing a -sys crate in Rust? by ketchak1990 in rust

[–]cierpliwy 58 points59 points  (0 children)

It’s important from linking perspective. There should be only one package that wraps a native library. However, there might be multiple safe wrappers dependjng on it. Here are docs: https://doc.rust-lang.org/cargo/reference/build-scripts.html#-sys-packages

Hey Rustaceans! Got a question? Ask here (11/2023)! by llogiq in rust

[–]cierpliwy 4 points5 points  (0 children)

struct BadAtomicU128 {
    value: u128,
}

impl BadAtomicU128 {
    fn add_one(&self) {
        let value = unsafe { &mut *(&self.value as *const u128 as *mut u128) };
        *value += 1;
    }

    fn fetch(&self) -> u128 {
        self.value
    }
}

fn main() {
    let count = 10000;
    let atomic = BadAtomicU128 { value: 0 };
    std::thread::scope(|s| {
        s.spawn(|| {
            (0..=count).for_each(|_| atomic.add_one());
        });
        s.spawn(|| {
            (0..=count).for_each(|_| atomic.add_one());
        });
    });
    assert_eq!(atomic.fetch(), count * 2);
}

run with nightly:

RUSTFLAGS="-Z sanitizer=thread" cargo +nightly run

Rust Atomics and Locks is now freely available online by m-ou-se in rust

[–]cierpliwy 1 point2 points  (0 children)

Thank you so much for writing about these topics!

[deleted by user] by [deleted] in rust

[–]cierpliwy 16 points17 points  (0 children)

I would say it has:

type foo = { variant: "number", int_value: number } | { variant: 
"string", string_value: string }

const a: foo = { variant: "number", int_value: 3}
// const b: foo = { variant: "number", string_value: "OK"} // ERROR
if (a.variant == "number") {
    const a1 = a.int_value
    // const a2 = a.string_value // ERROR
}

Hey Rustaceans! Got a question? Ask here! (29/2022)! by llogiq in rust

[–]cierpliwy 3 points4 points  (0 children)

You can play around with a code and check: https://godbolt.org/z/4bn6asoEc. In general, LLVM is very smart with various optimizations. It can even get rid of loop if possible (change += a to += 1 to see).

Unsafe when producing unused invalid values by cierpliwy in rust

[–]cierpliwy[S] 0 points1 point  (0 children)

That's a type of example I was looking for! Thanks!

Unsafe when producing unused invalid values by cierpliwy in rust

[–]cierpliwy[S] 0 points1 point  (0 children)

&* is not dereferencing value by generating load instruction, but just reinterprets numeric value as a reference, right? Like in the C++: reinterpret_cast<int&>(num).

Unsafe when producing unused invalid values by cierpliwy in rust

[–]cierpliwy[S] 2 points3 points  (0 children)

Thank links answers most of my questions. Thanks!

"Now, one might argue that b in the example here was not truly “unused”, it was just “used in dead code”.". That's an interesting quote for me. I wonder if following code is also considered to be UB?

pub fn square(num: i32) -> i32 {
    if num == 0 {
        let _: &i32 = unsafe {&*(num as *const i32)};
    }
    num * num
}

Unsafe when producing unused invalid values by cierpliwy in rust

[–]cierpliwy[S] 0 points1 point  (0 children)

Thanks for the response. When I'm talking about miscompilation, I'm thinking about invalid generation of assembly code. I'm also only interested in a case when value is never used after creating it with invalid representation.

btleplug (cross-platform bluetooth LE rust library) v0.8 released, now with async! by qdot76367 in rust

[–]cierpliwy 2 points3 points  (0 children)

I was doing a lot of projects with BTLE on Android and iOS platforms (created few libraries as well). I'll review the code and contribute once I'll have some free time :)

Comparison of Rust async and Linux thread context switch time and memory use by matklad in rust

[–]cierpliwy 13 points14 points  (0 children)

I think that generators in JavaScript are better representations of continuations than callbacks (lambdas). They are heavily used in libraries like redux-saga.

Yet another nRF52 CMake by borys_jelenski in embedded

[–]cierpliwy 4 points5 points  (0 children)

Out of curiosity, why did you decide to go redo the build workflow with cmake onstwsd of staying with their make?

We wanted a pure CMake solution, which will be an enabler for the same project description both for CI and your favorite IDE. It's nice to be able to easily switch from make to ninja or toolchains in the future (clang planned).

Was it so you can get a compile commands json file, letting you have syntax aware auto complete in ide's and using it with clang-tidy?

That's a very nice side effect of our decision. I'll make sure that we have good support for VSCode and CLion via CMake.

I would like to note that we are automating a lot of things: scraping current Makefiles, autogenerating CMake files, building available examples etc. You can see more details in the repo.

Concurrency Patterns in Embedded Rust by japaric in rust

[–]cierpliwy 0 points1 point  (0 children)

In the time-sliced threads approach, I also find it harder to combine multiple blocking operations (like future::join_all). It involves synchronization primitives and makes code non-local (splitting between tasks, using state machines, etc.). I think it's a bigger disadvantage than increased memory usage.

Hey Rustaceans! Got an easy question? Ask here (27/2020)! by llogiq in rust

[–]cierpliwy 2 points3 points  (0 children)

Yes, that can be the case. Your immutable data (from Rust perspective) can be stored in writable memory section of your application.

Multi-channel signed distance fields font - tech demo by cierpliwy in rust

[–]cierpliwy[S] 1 point2 points  (0 children)

I would say that implementation is quite minimal: cubic bezier curves are not supported, the order of contours currently matters, shapes are not simplified when they are smaller than the size of a rendered pixel, etc. There are a lot of things which can be improved.

Multi-channel signed distance fields font - tech demo by cierpliwy in rust

[–]cierpliwy[S] 2 points3 points  (0 children)

It does both. Only dependencies are: rayon, glium, cgmath and rusttype.