[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


Janitor application acceptance emails are being sent out. Please remember to check your spam box!


[Advertise on 4chan]


File: 1750482004674616.png (119 KB, 2400x2000)
119 KB
119 KB PNG
What are you working on, /g/?

Previous: >>107113418
>>
cniles be like
>i need to use a boolean!
>#include <sexually transmitted disease bool dot h>
>>
>>107133087
handy chart. have a you
>>
>>107133099
>cniles
>bool
int or setting bits
bool is gay
>>
>>107133388
bools are for the compiler, not storage
>>
I'm trying yet another way of doing gitignores:

# Ignore all directories at root
/*/
# Allow source dir
!/src/


Most programming langs don't produce _files_ straight into the repo root (some do), so this works out quite well. Some langs will still need a bit of tuning, like __pycache__, but it's not bad.

I've tried e.g. `*` and `/*`, and then allow listing, but that's tedious.
I think this will also have the side effect of not dumping random files at repo root, I'll rather put them in a directory if I don't want them in git.
>>
>>107133087
>cm
>km
huh?
>>
>>107133442
mm->cm->dm->m->dam->hm->km
mili->centi->deci->unit->deca->hecto->kilo
>>
on another note i think i got my version of seeking bits
i have yet to fix my mask, and test it, but i think its correct
idk how its gonna stack up with other versions though
i have only 3 conditionals so it should be decently fast
but because i have only 3 conditionals, theres some operations that i do but i dont actually need
it should perorm decently well on small lengths because instead of looping through 1 byte at a time i parse them by bunches of 0s and 1s

i still have to test it though
knowing myself theres 100% something ive forgotten about
its gonna happen later though its been something like 3 hours im hacking at this problem, i need a break
>>
>>107133388
my leetcode problem requires me to use bool
>>
>>107133435
You can just modify the gitignore file when you need to.
>>
>try to solve a leetcode problem for an hour using C
>fail
>switch to python
>solve in 5 minutes
fucking crazy
and yes it's 100% a skill issue but god damn
>>
>>107133987
its a different class of language.
completely different usecase
>>
>>107133987
>>107134003
cont
its like comparing a scalpel (C) to an axe (python)
you can cut a tree with both
same with performing surgery
but for either case what makes sense is using one or the other
>>
>>107134003
im just not used to thinking at the autism low level
like once I got the implementation in a higher level language it's relatively easy to translate it to C since it basically just adds more steps
but starting from scratch in C is rough since it doesn't give you many of the comfy abstractions
>>
>>107134084
>comfy abstractions
such as?
also, which leetcode problem filtered you?
>>
>>107134061
C is closer to a sharpened rock than a scalpel, given how both are unfixably primitive as fuck and require a lot of hacking to get even simple things done
>>
>>107134084
heh. my brain is thoroughly warped low-level-wise because ive been using C more or less exclusively, during the past 6 years
but if i dont need to go low, i dont.
amdahls law:
you dont want to waste time optimizing code that accounts for 0.1% of your runtime
you want to optimize stuff that actually matters

this also goes for languages.
if i have to do some scraping, you can be sure ill be using paiton + beautifulsoup
unless the data collection takes longer than the desired data resolution

>>107134153
nono
a well sharpened scalpel
you have compiler hints, in syntax, or as pragmas/attributes, various flags, intrinsics
its the most granular language short of asm
>primitive
thats its selling point.
both as a learning tool, and in situations where individual reads matter or a float multiplication accounts for half your runtime
attempting to satisfy the usecase for C with higher level, more feature rich languages is like writing a letter while wearing boxing gloves
>>
File: damn-bitch-wobot.jpg (120 KB, 1023x481)
120 KB
120 KB JPG
>>107134199
>feature rich
even that is not accurate
you got features of the wazoo with the c ecosystem
gorilions of compiler flags
attributes and pragmas for everything you might want
mature analysis tools

the language itself looks barebones.
but even that is misleading

a * b * c * d is not the same as (a * b) * (c * d)
c is actually subtle as fuck. extended c that is
the standard is kinda shit and the comittee people are autistic (mentally retarded)
>>
>>107134263
>comittee people are autistic (mentally retarded)
minus eskil steenberg.
i like that guy
>>
>>107133556
What does masking_mask do?
>>
>>107134199
That's why non-larpers use C++.
>>
>>107134263
integer multiplication is associative. fp multiplication isn't because it's ieee, c had no hand in that.
>>
>>107134570
fp addition can't be associative in any useful way can it
dunno about multiplication
>>
>>107134130
>such as?
nigga you serious? literally just go and compare python vs C solutions to anything lmao
>>
>>107134676
you can't name one?
>>
>>107134696
it's very unhealthy for your brain to try to ragebait people on the internet
ps. I'm exiting the thread now.
>>
File: st 2025-11-07 19:36:27.jpg (135 KB, 855x453)
135 KB
135 KB JPG
The year of C++ modules.
>>
I'm building a static site generator, or what I think Hugo does. Using this as Rust practice.
I'm getting bored though. Another project that I probably won't finish.
>>
>>107133556
Tried running it, it failed in this case that doesn't use the mask table.

Mismatch: len = 2

New 0 = 0 Old 0 = 0
New 1 = 139 Old 1 = 66

{0x0, 0x55555555555555d, 0x7fff80007fff800,
>>
>>107134199
it's a rock
a fucking fossil that has no place anywhere near modern applications
>>
File: tech-support.jpg (261 KB, 694x1000)
261 KB
261 KB JPG
>>107134570
its not what this is aboot
parenthesis hint to the compiler the dependency of operations
because of that when you use parenthesis the compiler stores the intermediary result in discrete registers.
and thanks to that the contents of the parenthesis can be computed separately, allowing the compiler to leverage instruction level parallelism

well, in this exact case thats what happens if you compile with -O0, any optimization turns that into a regular multiplication because in this exact case its not worth it i suppose

>>107134438
umm, masking? kek.
it sets the bits that have already been processed to zero so that tzcount gives an accurate offset

>>107134542
sepples is c but for big corpos
and no, this isnt a compliment if you give it a fink

>>107134905
kek, didnt even have time to run it myself, yet
i just came back from a grocery run
{0x0, 0x55555555555555d, 0x7fff80007fff800}
this is the array i presume?
>>
File: h-cube.png (159 KB, 900x444)
159 KB
159 KB PNG
>>107134928
you have no idea what youre talking about
to illustrate it:
take a guess what language this code is from?
    float tmpSum = 0;

if (ROW < N && COL < N) {
// each thread computes one element of the block sub-matrix
for (int i = 0; i < N; i++) {
tmpSum += A[ROW * N + i] * B[i * N + COL];
}
}
C[ROW * N + COL] = tmpSum;
>>
>>107135003
whatever the language, it's written by a caveman that doesn't use iterators or proper function/method splitting

so again, proving the point that c is primitive and has no place anywhere near modern applications
>>
File: oof.jpg (22 KB, 480x360)
22 KB
22 KB JPG
>>107135080
its cuda
now feel free to take your redditspacing back where you came from <3
>>
File: 1750677145116577.jpg (26 KB, 500x500)
26 KB
26 KB JPG
I'm currently working with C. How useful do you think a function like the following is:
bool equal(const char *s1, const char *s2) {
return strcmp(s1, s2) == 0;
}

I'm a bit torn apart, on one hand I think it makes the code more readable, on the other hand I don't want to clutter my program with helper functions like these that solve only a very little problem, as strcmp(s1, s2) == 0 is probably almost as readable to a c programmer. What do you think?
>>
>>107113513
>>107113592
>>107134930
This is the test generator I'm using: https://pastebin.com/wxvV6Q1y
>>
>>107135112
thanks
ill certainly give it a whirl.

>>107135110
iunno.
if i were you id reimplement string ops instead.
for proper string types: wrapepd in a struct, with a size, and extra padding so you can make maximum use of vectorization while keeping your strings compatible with c interfaces
>>
>>107135110
>>107135154
abt vectorization: you have to align your data to 32 bytes when you use __mm256 types and to 16 bytes when you use __mm128
for maximum comfiness i use/allocate unions instead to have a comfy and legal way of accessing the underlying data reagrdless of the type
>>
>>107135112
>>107135154
Crap the pattern count at the main loop only goes up to 9...
>>
>>107135191
? whats the implication?
>>
>>107135209
It's a mistake, set it to 21
>>
>>107135110
should be called str_iseq or something. But yeah !strcmp can be confusing even for someone experienced.
>>
>>107135223
ah, in the utility
ok
ill keep that in mind
i was compiling the code for the first time on my end
aaaaand... (rolling drums)
41 lines of errors. kek
gimme a moment
>>
>>107135185
No you don't have to.
>>
>>107135154
>if i were you id reimplement string ops instead.
that's overkill for the program I'm writing, I really just need to occasionally compare small strings, this is really not the bottleneck in my program. but sounds like a fun project
>>107135239
alright, I will keep it then. I just thought maybe I'm retarded for writing this function
>>
>>107133442
>Distance which light travels while the operation is performed
did you miss that?
>>
File: modern-sepples.jpg (149 KB, 800x533)
149 KB
149 KB JPG
>>107135296
if you dont you cant pass an union member or the union itself as argument without using an unaligned load
which has ~4cycles latency iirc
i noticed even aligned loads and casts have a cost it seems.
but maybe thats bc of data dependency which forces a fence which prevents the cpu from ovelapping latencies in the following operations
didnt go to the bottom of things on that one

>>107135309
>that's overkill for the program I'm writing
100% fair but its a necessity whenever stringops are a meaningful portion of performance critical code
the libc is gimped by the fact it assumes non-padded null terminated strings
you can be an entire order of magnitude slower using vanilla libc compared to semi competent homebrew, if not worse
>>
>>107135110
>I don't want to clutter my program with helper functions like these
your program is literally just one function: main. everything else is a helper, so don't be shy about writing small utilities. depending on the size of your project, you probably want to do this regardless, in case you want to change the string type in the future (to use slices, for example, as the other poster suggested)
>>
>>107135369
>muh unions muh latency
that's enough lil bro, asking each character in a string to be aligned to 16 bytes is peak mental illness.
>>
File: annoyed-pepe.jpg (73 KB, 750x1000)
73 KB
73 KB JPG
>>107135416
were talking about vector types here, try to keep up
>>
>>107135427
Then mention of unions makes even less sense you stupid nigger.
>>
File: same-same.jpg (22 KB, 321x300)
22 KB
22 KB JPG
>>107135504
dats bc u dum
and flamey

arent you a shartoid perhaps?
on another note, if you ask nicely i can explain to you things and the stuff theyre made of
>>
>>107135080
what about a for loop scares you?
>>
>>107135518
I already know that your skull is filled to the brim with diarrhea because the BBC stuck in your ass still wasn't removed.
>>
>>107135583
>bibisi
i knew youre a shartoid
youre easy to spot
ur just fucking retarded
>>
File: 1758588346730327.png (146 KB, 680x681)
146 KB
146 KB PNG
>>107135583
>>
>>107135645
nah its a sharty thing
>cobson ridin that bibisi
have a look at their site sometime
their whole culture fits on one post it
once you understand what theyre about, theyre easy to spot
report and move on
theyre here to troll
thats why they dont make sense whatsoever
>>
>>107135635
>>107135645
>>107135670
what does big black coalstone have to do with any of this
>>
>>107135683
idk, you brought it into the discussion
i am perfectly happy discussing vectors
>>
>>107135369
thanks for the insights, senpai
I didn't understand all of it, but a custom string data type sounds like a cool thing to do to get into vectorization, which I have no experience in currently
>>107135378
>don't be shy about writing small utilities
will do

so how would you handle helper utility functions in c, in the same file, include another .c file, or write a .h and .c with these functions and include the .h?
>>
>>107135729
for something like that, static inline in a header file that gets included everywhere.
>>
File: 1731913350140843.png (1.45 MB, 1328x1328)
1.45 MB
1.45 MB PNG
>>107135817
ah yes, I thought that a header without the implementation would be weird, but including a c file is also weird, and keeping it in the same file is also weird... this solution seems to be the best

pretty comfy general you have here
>>
File: change-my-mind-a.jpg (298 KB, 950x960)
298 KB
298 KB JPG
>>107135729
>senpai
i barely learned vectorization myself
but its indeed a powerful tool
i wrote an ascii to float that takes 1.5-3 cycles per character read, with better results with bigger strings
ngl im pretty happy with myself, light testing yields that im ~2.5x faster than strtof on a typical string
maybe more bc theres the launch overhead, and the control additions, which souldnt amount to much on 22.6 and 50.9 seconds respectively
heres the code if you wanna have a look
https://files.catbox.moe/1zq8zw.c
you need -mavx2 and -mbmi flags to compile it
and yeah, i cheated a little bit. i take in max 32bytes for integers, 32max for decimals but its not hard or expensive to generalize it into arbitrarily long sequences of numbers
>>
>>107135877
>takes 1.5-3 cycles per character
how would you know that? so far, I have only used tools like perf to see how much time which function takes, but how would you estimate the number of cycles used?
>>
>>107135942
its an estimation
but i take the time a run takes, in seconds
like 1B iterations
then plug in the clock speed
so
(time * clock speed)/iterations = cycles
and it more or less works. it gives figures in the ranges presented in ops picrel when you compare changes
>>
>>107135983
>it gives figures in the ranges presented in ops picrel when you compare changes
(or these you see in the documentation)
im conservative in speeds bc i heard ryzens slightly throttle when using avx2. actually all consumer grade processors do



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.