|
Turn on the PC, and ... one of my monitors has died.
Powers up, shows the LG logo, detects cable, but won't ID to windows. Checked the cable, the display card connector - it's the monitor.
So now I need to replace that, and asap ... hello Amazon, what have you got for me? Hmmm ...
At least the day has to get better from here, right?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I would not count on it.
A few weeks ago I had what looked like a starting chimney fire so I had to call the fire department to care of it/check it.
A few hours later one of the thermostats om my central heating system decided to call it a day and went up in smoke with the smell of roasted electronics to go with it.
So: don't count on things getting better, they might but you never know, murphy and all that.
|
|
|
|
|
As I sat in my gloom, a voice came to me saying "cheer up, things could be worse". So, I cheered up. And things got worse.
Bad things come in 3's. My grandmother from Bolton taught me that.
Don't whine, you still have a monitor.
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
theoldfool wrote: Bad things come in 3's.
I was just about to write that.
Real programmers use butterflies
|
|
|
|
|
You mean you didn't have a backup monitor? Shame on you.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
I had 2 x 22" (one landscape, one portrait), and an old 18" square one (it used to be Herself's) so there are backups - but I miss my landscape monitor - it's where all the "real work" got done. It was reserved for "full screen" aps: Word, Excel, VS, with Chrome on the portrait, and email / small stuff on the square one.
I've ordered a new 27" to replace it which should be here tomorrow (and hopefully canceled the 24" I did order but which post-order can't be delivered until the 18th).
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
A tale of two functions:
int max(int x, int y) {
if(x>y)
return x;
return y;
}
and
int max(int x, int y) {
return x*(x>y)+y*(x<=y);
}
do the same thing
one is much harder to read, but also optimizable in ways the other isn't.
the CPU really likes code like the second one. Even with the extra multiplies, you can use SIMD instructions to pay for that overhead, while the code doesn't interfere with branch prediction
but coding without ifs gets weird really fast. The above is simple. Now add code to do the same thing but operate on 4 32-bit ints at a time so that it efficiently uses SIMD. Or do something more complicated than finding a max of two values and you'll see what i mean.
Smart optimizing compilers can do some of this, and much of the stdlib is already optimized with simd instructions and branch prediction in mind, but when you're trying to squeeze every last cycle out of your CPU you have to take things into your own hands.
It's not something I'd normally do, but I'm working with a codebase that's already highly optimized, to try and make it faster. So this is par for the course.
Real programmers use butterflies
|
|
|
|
|
What about a ternary operator?
|
|
|
|
|
That's just an abbreviated if statement.
Real programmers use butterflies
|
|
|
|
|
The price of salt has lately gone up so much that today, I enjoyed my breakfast egg without salt.
|
|
|
|
|
Enough to make you weep....
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Hmmm... Your second post on this subject. Do you have a quantum computer in your basement, and need to pay strict attention to the Copenhagen Interpretation?
|
|
|
|
|
No, but I have steve wozinak (the only good thing about apple) in my basement. I lured him there with cookies and promise of a new NeXT
Real programmers use butterflies
|
|
|
|
|
int max(int x, int y) {
return x*(x>y)+y*(x<=y);
}
| |
| OPTIMIZATION |
| OPTIMIZATION |
| OPTIMIZATION |
| OPTIMIZATION |
| OPTIMIZATION |
| OPTIMIZATION |
---- ----
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\ /
\/
int max(int x, int y)
{
if (x > y)
return x;
return y;
}
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
that would figure
Real programmers use butterflies
|
|
|
|
|
This version uses table lookup, no branching.
int max(int x, int y)
{
int arr[2] = {y, x};
return arr[(int)(x > y)];
}
|
|
|
|
|
well played
though you do some memory writes there, which might not be a great thing. then again, it might never leave CPU cache anyway. it's definitely more readable than my approach.
Real programmers use butterflies
modified 8-Jan-21 8:56am.
|
|
|
|
|
In this example the branch prediction won't be an issue. It will basically skip only a few statements. The cost of the multiplications will be significant.
|
|
|
|
|
weird then that my stdlib implementation is branchless. also i'd have to check but i think the compiler can generate better instructions for multiplies by 1 and 0
Real programmers use butterflies
modified 8-Jan-21 10:19am.
|
|
|
|
|
is SIMD a medication your on to prevent writing maintainable code ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Yes. It makes my code execute sometimes 16x as fast.
Real programmers use butterflies
|
|
|
|
|
Can I have some of what you're having ?
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
|
|
|
|
|
Sure!
avx implementation of strstr() by Wojciech Muła
SIMD-friendly algorithms for substring searching[^]
I didn't make my own because i'm allergic to bugs. this compares 16 bytes at a time.
#define _mm512_set1_epu8(c) _mm512_set1_epi32(uint32_t(c) * 0x01010101u)
size_t avx512f_strstr_v2_anysize(const char* string, size_t n, const char* needle, size_t k) {
assert(n > 0);
assert(k > 0);
const __m512i first = _mm512_set1_epu8(needle[0]);
const __m512i last = _mm512_set1_epu8(needle[k - 1]);
char* haystack = const_cast<char*>(string);
char* end = haystack + n;
for (; haystack < end; haystack += 64) {
const __m512i block_first = _mm512_loadu_si512(haystack + 0);
const __m512i block_last = _mm512_loadu_si512(haystack + k - 1);
const __m512i first_zeros = _mm512_xor_si512(block_first, first);
const __m512i zeros = _mm512_ternarylogic_epi32(first_zeros, block_last, last, 0xf6);
uint32_t mask = zero_byte_mask(zeros);
while (mask) {
const uint64_t p = __builtin_ctz(mask);
if (memcmp(haystack + 4*p + 0, needle, k) == 0) {
return (haystack - string) + 4*p + 0;
}
if (memcmp(haystack + 4*p + 1, needle, k) == 0) {
return (haystack - string) + 4*p + 1;
}
if (memcmp(haystack + 4*p + 2, needle, k) == 0) {
return (haystack - string) + 4*p + 2;
}
if (memcmp(haystack + 4*p + 3, needle, k) == 0) {
return (haystack - string) + 4*p + 3;
}
mask = bits::clear_leftmost_set(mask);
}
}
return size_t(-1);
}
Real programmers use butterflies
|
|
|
|
|
Yesterday Her Dell desktop's CPU fan started making grinding noises . I left it alone, kind of hoping it will behave today. Well, no, it got worse. Checked with Dell and her machine is 5 weeks out of warranty. They wanted to sell me a fan/heatsink combination for over $200! Yikes! Then I had a moment of inspiration. I had a much older Dell, which I had previously stripped of its hard drives, just gathering dust. I hauled its fan out and it was an exact match for her machine's fan.
So now Her machine is running silently with an old fan. I checked the factory label on the failed fan. It proudly boasted that it had some "hydrodynamic" bearing. Well, Mr. Dell, your hydrodynamic bearing went for a swim and drowned! Now I also know what to avoid if I ever have to buy another fan!
Get me coffee and no one gets hurt!
|
|
|
|
|
My desktop has a noisy fan - but only when I turn it on in the morning and everything is cold. One of these days I must find out which one it is and replace it, but since it means me trying to do that before my first coffee it is not such a simple task ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|