|
Just casual 10k+ chars long symbols. This language is great
|
# ? Nov 30, 2021 00:47 |
|
|
# ? Jun 8, 2024 07:01 |
|
cheetah7071 posted:What might cause a function to be so un-linked that the compiler doesn't even know its name? I'm getting this error, with only information about which project and which .lib file the error was in This either should work or shouldn’t compile, depending on what comes before, but MSVC is a very weird compiler.
|
# ? Nov 30, 2021 03:45 |
|
Xarn posted:Just casual 10k+ chars long symbols. This language is great When I started using C, you had to make do with 8. You could still use longer names, but external symbols were silently(!) truncated. Also, most compilers would reduce the limit to 7 because they always inserted an underscore at the beginning for arcane reasons. The limit was imposed by the object file format, not the language.
|
# ? Dec 1, 2021 02:10 |
|
Is there a generally better way to read small amounts of information from a large number of files on the hard drive, than something likecode:
I'd think this is just how it always works, but when I use programs written by other people, they never seem to have this problem, which is what makes me think that maybe there's a trick I'm not aware of
|
# ? Dec 3, 2021 21:33 |
|
Are you limited to standard C++?
|
# ? Dec 3, 2021 21:35 |
|
Xarn posted:Are you limited to standard C++? I'm free to add a library dependency, if that's what you're asking
|
# ? Dec 3, 2021 21:35 |
|
Which OS you're on may matter a lot. Also if are you using spinning media or SSDs? (Linux has bad file system performance. Windows and Mac are much worse).
|
# ? Dec 3, 2021 21:44 |
|
This is Windows, on an SSD to be honest the frustrating part is less the slowness and more the inconsistency. If it was just slow I could rewrite my code to not do a first-pass read of the headers. But when it randomly decides to be fast, getting the header info before doing a second-pass full read of the files is much, much faster. And again, when I run binaries written by other people that are doing very similar things under the hood (but I don't have access to the source code so I can't be completely sure), the header-reading step seems to be consistently very fast.
|
# ? Dec 3, 2021 21:47 |
|
Never mind, I'm a big dummy. There's still some variability, but the insane thousand-fold slowdown I was getting today which caused me to write my post was because I was compiling in debug mode If there's a better way than what I have posted I'd still love to hear it though, because I do get random 2- or 3-fold slowdowns even when I'm not being a dummy
|
# ? Dec 3, 2021 21:49 |
Do the work in parallel and use the native Win32 functions for "overlapped IO". That's the Windows kernel term for asynchronous, event driven file access. You'd first issue a large number of overlapped CreateFile calls, and for the completion of each of those trigger overlapped seek and read operations. Theoretically, issuing more IO operations at once should allow the device drivers and storage controller combine and reorder requests into what's most efficient for the actual physical representation. It's also a lot more work writing and ensuring the code is correct. nielsm fucked around with this message at 05:07 on Dec 4, 2021 |
|
# ? Dec 3, 2021 23:42 |
|
This seems somewhat relevant - and is kind of neat in general: https://www.youtube.com/watch?v=qbKGw8MQ0i8 Their biggest simple upgrade doesn't really apply to you, though - a big difference between Windows and the others is that in Windows, closing a file only returns after syncing to disk, while in the other OSes it returns immediately and syncs in the background. Which means that if you were writing to a lot of files, it makes sense to have a lot of threads set aside just to wait for the close operations. Computer viking fucked around with this message at 00:50 on Dec 4, 2021 |
# ? Dec 4, 2021 00:46 |
|
nielsm posted:Do the work in parallel and use the native Win32 functions for "overlapped IO". That's the Windows kernel term for asynchronous, event driven file access. Beware, unless you are already familiar with MS's docs so you know how to read them, this is fuckton of work. Depending on what you are gonna do with the files afterwards, you can try memory mapped IO and Boost to abstract over it if you plan to port the code to different platforms.
|
# ? Dec 5, 2021 18:12 |
|
Xarn posted:Beware, unless you are already familiar with MS's docs so you know how to read them, this is fuckton of work. Wouldn't a library like libuv help in this situation? As in, provide the async IO without having to get dirty with the Win32 functions? And still have some hope that the IO code is at least somewhat correct?
|
# ? Dec 5, 2021 19:25 |
|
I am betting that online course or whatever calling for an observer-subject assignment didn't mention what to do about object lifetime management. I think that just gets overlooked in general with that pattern and they should go through some strategies with it. You can even screw yourself up with it in languages/runtimes that manage memory by keeping references to objects that you otherwise no longer cared about.
|
# ? Dec 14, 2021 19:40 |
|
Do you guys do C# in here? I'm just looking for some (hopefully free) online tutorials to help me continue my learning. I finished a semester in school and we have this stupid loving "book" where we have access to it virtually for 4 months (full price) and then we lose access at the end of the semester so I don't have that resource anymore. I'm going to check out W3 Schools I think first. Any other in depth guides?
|
# ? Dec 18, 2021 14:15 |
Try the .NET thread for C# talk.
|
|
# ? Dec 18, 2021 14:32 |
|
nielsm posted:Try the .NET thread for C# talk. Thanks!
|
# ? Dec 18, 2021 17:26 |
|
I've been smacking my head against C++20 modules for a while now and I just haven't been able to get my code to compile. Is anybody able to explain to me why this tiny solution doesn't compile in Visual Studio 2022? If I can find out why it is failing, I would be one step closer to getting my project to compile. I get the following error: C7621: module partition 'Part' for module unit 'File' was not found. The project: https://drive.google.com/file/d/1-9Rotd3c2qSmr1esoYs-1YTQmCYL1oMk/view?usp=sharing
|
# ? Jan 3, 2022 11:00 |
|
Well, I think I've figured it out. Visual Studio 2022 17.0.4 cannot have a module implementation unit of a partition. I'm not sure if this is a limitation of modules or a bug with Visual Studio, but I can work around it by either not using partitions or only using partitions without an implementation unit.
|
# ? Jan 4, 2022 18:16 |
|
I'm trying to get an application that's using the simde library for portable SIMD to run happily on Apple Silicon. So far, the biggest tripping point is that ARM NEON bit-shifting operations can only be called with a compile-time constant offset. For example, I'm calling _mm_slli_epi64, which simde is mapping onto these NEON instructions like vshlq_n_s16. I can't find an elegant way to make sure that these always are called with compile-time constants, as we had wrapper functions around them and as I understand it, there's no way to guarantee that a function is called only with compile-time constants, so I changed the functions into macros. The other problem that I had is a small number of places where these were called with runtime variables, which I could build a lookup table like this project did: https://github.com/VectorCamp/vectorscan/pull/81/files#diff-1f738fe3ab986614e926b3ce01fcd42dbf3e8ccb79337931af69450f56319554R178 Doing a lookup table like that feels incredibly repetitive and inelegant, is there some way with templates to create something like this over a range of numbers that I define? code:
|
# ? Jan 14, 2022 23:53 |
|
NEON has "shift by a runtime value" operations (e.g. vshlq_s16 instead of vshlq_n_s16), it seems strange that your portability library is using the compile-time-constant-only variant of the intrinsic to emulate an SSE instruction that isn't restricted to compile-time constants.
|
# ? Jan 15, 2022 03:49 |
|
C++20 introduces consteval, which can force a function to be evaluated at compile-time.code:
EDIT: Some searching shows this C++17 based solution: code:
Nalin fucked around with this message at 07:04 on Jan 15, 2022 |
# ? Jan 15, 2022 06:51 |
|
Twerk from Home posted:The other problem that I had is a small number of places where these were called with runtime variables, which I could build a lookup table like this project did: https://github.com/VectorCamp/vectorscan/pull/81/files#diff-1f738fe3ab986614e926b3ce01fcd42dbf3e8ccb79337931af69450f56319554R178 code:
|
# ? Jan 15, 2022 07:18 |
|
Yep. All compilers will constant fold the switch variant. At least as long as the number is known at compile time and not the result of some atoi() or something.
|
# ? Jan 15, 2022 09:45 |
|
Jabor posted:NEON has "shift by a runtime value" operations (e.g. vshlq_s16 instead of vshlq_n_s16), it seems strange that your portability library is using the compile-time-constant-only variant of the intrinsic to emulate an SSE instruction that isn't restricted to compile-time constants. I looked at vshlq_s16, it looks like it takes a vector instead of an integer as the argument to shift by, so if I wanted to bit-shift a whole vector by 4, I'd need to create a second vector of equal length and fill it with 4s. I appreciate all of the suggestions that people gave here! The project is using C++11, and I think that the lookup table will be easier to live with, given that it's only needed in one place. The value to shift by is actually determined at runtime, so maybe I should inline the function to keep overhead reasonably small.
|
# ? Jan 15, 2022 21:16 |
|
I'm trying to figure out how to write a const getter for this class. It is an object that gives you access to an object while it locks a mutex for the duration of the lifetime of a ProtectedObjectAccess object. I'm not sure if I need to include that code.code:
code:
|
# ? Jan 19, 2022 03:59 |
|
baby puzzle posted:I get an error because Get() isn't const, so I can't call it. I'm having a hard time figuring out how to write a const version of the Get() function. This whole thing looks like a horror though.
|
# ? Jan 19, 2022 04:43 |
|
A locking wrapper like that isn’t the craziest thing — Rust does something like it — but you should really take the locked operation as a lambda argument or something instead of trying to return some sort of guarded value. And yes, you will need to make the mutex mutable. Also, it probably shouldn’t be a recursive mutex, because any time you find yourself wanting a recursive mutex is a time when you need to back up and completely rethink what you’re doing.
|
# ? Jan 19, 2022 07:27 |
|
I think I'm just gonna const_cast when I need to.. e: i'm drunk and being gross. nvm. baby puzzle fucked around with this message at 09:48 on Jan 19, 2022 |
# ? Jan 19, 2022 09:41 |
|
rjmccall posted:but you should really take the locked operation as a lambda argument or something instead of trying to return some sort of guarded value. This is the correct solution.
|
# ? Jan 19, 2022 13:06 |
|
Probably. I'm always using in cases like this, at the top of a scope. Just to make it easy for me to see if I'm using it improperly. But of course I can still easily do the wrong thing with it.code:
|
# ? Jan 21, 2022 07:22 |
|
The idea is that you write something like this (add forwarding constructors and proper return types and so on as needed)C++ code:
C++ code:
|
# ? Jan 22, 2022 13:46 |
|
Xarn posted:So that the users of the synchronized value don't have to fiddle around with mutexes and lock lifetimes. Edit: you could also combine the annotations with this template idea, which would prevent you from doing a lock-mutex from within another lock on the same mutex, for example.
|
# ? Jan 22, 2022 17:31 |
|
Xarn posted:The idea is that you write something like this (add forwarding constructors and proper return types and so on as needed) Doesn't this get a bit unwieldy if you have more than one locked value? Although I guess you could call .do_locked() on other objects inside of lambdas.
|
# ? Jan 22, 2022 19:39 |
|
Yes if they are independent (so they should logically get their own mutex) and yes.
|
# ? Jan 22, 2022 20:22 |
|
If you're locking two mutexes at the same time, you are well on your way to deadlocktown and should do a bunch more thinking
|
# ? Jan 22, 2022 22:40 |
|
Foxfire_ posted:If you're locking two mutexes at the same time, you are well on your way to deadlocktown and should do a bunch more thinking
|
# ? Jan 22, 2022 23:56 |
|
If they’re not independent, you can of course just make the locked value a struct. As a general rule, some people struggle with just making new types when they’d be useful, as if writing the struct keyword was some enormously fraught undertaking. If you are one of them, that is a good instinct to drive out.
|
# ? Jan 23, 2022 00:15 |
|
roomforthetuna posted:And if it turns out you *must* do that for some reason, this is a really really great time to set up those thread safety annotations! ABSL_ACQUIRED_BEFORE and/or ABSL_ACQUIRED_AFTER is a good way to be confident you're not causing two-lock deadlocks. Orrrr you can use std::lock, which afaik guarantees no deadlocks when acquiring multiple mutexes. rjmccall posted:If they’re not independent, you can of course just make the locked value a struct. I sometimes have this problem and my first idea was fo frankenstein together a variadic version of the wrapper
|
# ? Jan 23, 2022 00:43 |
|
|
# ? Jun 8, 2024 07:01 |
|
Xarn posted:Orrrr you can use std::lock, which afaik guarantees no deadlocks when acquiring multiple mutexes. This doesn't help if your usage pattern involves doing work while holding lock 1, then acquiring lock 2 without releasing lock 1, then doing more work.
|
# ? Jan 23, 2022 01:01 |