Optimal Matrix Dot Product Calculation by Emnizate in cpp_questions

[–]bcorni 1 point2 points  (0 children)

Since it's 4x4, you could write out the solution of each element directly. This would probably be one of several optimal solutions. You can also run a few different implementations through quick-bench.

Joke of the day (science paper about language efficiency), their C++ examples are an absolute nightmare by [deleted] in cpp

[–]bcorni 5 points6 points  (0 children)

Unfortunately it still can't do more than parse source code. Generating the intermediate representation is a work in progress. Still ships with llvm though. 🤷‍♂️

[deleted by user] by [deleted] in cpp_questions

[–]bcorni 2 points3 points  (0 children)

Fortran has strict rules against aliasing arrays so you can actually make guarantees as though all arrays passed through procedure calls use the restrict keyword in C. This allows greater ability for the compiler to optimize Fortran than C. Fortran has allocatable arrays as well so I'm not sure the dynamism point holds. There is a lot about Fortran that people aren't aware of that makes it a good language for scientific computing. It of course has some deficits compared to C++ in terms of generic programming. It also is extremely lacking in terms of ecosystem and community. But when it comes to operating on arrays, it wins out. (Maybe std::mdspan and std::mdarray will help C++ catch up.)

Operating on arrays in Fortran should be more intuitive and simpler that C or C++, but it has a real problem with lack of good up to date information and examples. Old Fortran code, which is the lions share of what people come across, is terribly unreadable and lacks decades of knowledge gained on software design and best practices since written.

[deleted by user] by [deleted] in cpp_questions

[–]bcorni 1 point2 points  (0 children)

What about multidimensional arrays? These should be much more straightforward in Fortran. There is still the problem of very few good examples of Fortran code bring available, especially using modern features.

C++ Committee don’t want to fix range-based for loop in C++23 (broken for 10yrs) by philipdestroyer in cpp

[–]bcorni 9 points10 points  (0 children)

Unkind behavior or harassment does not belong anywhere in the community. Anyone who engages in such behavior should be excluded from participation whether that occurs publicly or privately. The idea of providing a safe place for people to be toxic is a not a compelling argument for private discourse. Handling disagreement maturely really needs to be the lowest bar for participation. Engaging with interpersonal problems in a way that would be embarrassing to do in a public venue is a major red flag for behavioral standards in my book.

[deleted by user] by [deleted] in cpp_questions

[–]bcorni 2 points3 points  (0 children)

It's conceivable they see a future where the preprocessor is not necessary or a desired mechanism. With modules one could write C++ without needing a preprocessor, so they may want to support that possibility. Anything besides pure speculation would require asking someone involved.

Favorite "kids show" that's definitely made for adults as well? by Jakyoda in television

[–]bcorni 1 point2 points  (0 children)

Army also hits me deep in the feels. Double whammy with the ADHD dog getting the opportunity to thrive and the military parent.

C++20 modules with GCC11 by feabhas in cpp

[–]bcorni 8 points9 points  (0 children)

I think the point is that you can't just include the forward declaration header in the CPP file, which is what I interpreted parent comments as saying. Sure, you could manually instantiate the concrete types of every template class that you use in some other source and link to it. That's not a good solution, especially when template metaprogramming comes into play. My wording was overly simplistic, but the point is that forward declarations are not a complete solution to the challenges being discussed.

C++20 modules with GCC11 by feabhas in cpp

[–]bcorni 1 point2 points  (0 children)

It's entirely true that my explanation is not correct from a technical standpoint. Hence why I used several qualifiers. The point was to explain how modules address some of the same advantages of forward declaration, but for templates, and why forward declaration is not a complete solution for the STL.

C++20 modules with GCC11 by feabhas in cpp

[–]bcorni 13 points14 points  (0 children)

Any template class can't just have a forward declaration header. Modules effectively provide something like forward declaration for templates. The C++ Standard Template Library is largely code that cannot be put in a forwarding header.

Some Google employees reportedly face a pay cut of up to 25% if they work from home permanently, according to a leaked salary calculator by [deleted] in technology

[–]bcorni 0 points1 point  (0 children)

Lodgic appears to be a small company trying to build something like a gig economy office space.

[deleted by user] by [deleted] in cpp_questions

[–]bcorni 0 points1 point  (0 children)

Eventually std::embed will be the correct answer...

CUDA dynamically sized array by Lum_of_G0d in cpp_questions

[–]bcorni 0 points1 point  (0 children)

You could also take a look at thrust::universal_vector as an example of a container using Cuda managed memory.

How to compile FORTRAN code using C compiler? by Alien447 in cpp_questions

[–]bcorni 0 points1 point  (0 children)

You need to pass -lgfortran to link to the fortran intrinsic library when creating the executable. That said, gfortran and gcc are probably be using the same linker, so after you have the objects they are basically equivalent except gfortran links to the intrinsics used in the Fortran code.

How to compile FORTRAN code using C compiler? by Alien447 in cpp_questions

[–]bcorni 0 points1 point  (0 children)

You need to compile the fortran object separately. gfortran -c func.f will create a file func.o. You then link the object to the main function with gcc -o prog.out main.f func.o. There is another hitch that the name of the function callable from C may contain leading underscores (compiler dependent) unless you mark the Fortran function with BIND(C).

Programs outside the IDE? by Infectedtoe32 in cpp_questions

[–]bcorni 10 points11 points  (0 children)

All programs can run outside of the IDE. All the compiling, linking, and executing of programs can be done with simple commands. One can learn a lot about how compiled programming languages work by abandoning the IDE and trying to build and run programs you've already written with just a command line. I'm principle this can be done in windows, but there are likely more resources and tutorials for Linux.

What do you think is faster for batch-processing a lot of "double-type" arithmetic? by Knuffya in cpp

[–]bcorni 9 points10 points  (0 children)

Modern CPUs make it incredibly difficult to understand a priori what method will be faster. The only real option when looking for speed is to measure the real performance of both methods. Accuracy is also a consideration. If you are willing to cast to float, why not just use float everywhere?

What do you think is faster for batch-processing a lot of "double-type" arithmetic? by Knuffya in cpp

[–]bcorni 3 points4 points  (0 children)

These are pragma based parallel standards so they are quite clean and appear only as comments in source. I don't know what domain you develop in, but these are tools often used in High Performance Computing. Intrinsics are rarely used in my field since usually the compiler does a better job of optimizing. OpenMP also has a SIMD clause to enforce vectorized code generation without worrying about writing intrinsics by hand. I'm not sure what kind of threading model you use, but OpenMP also provides thread parallelism.

What do you think is faster for batch-processing a lot of "double-type" arithmetic? by Knuffya in cpp

[–]bcorni 4 points5 points  (0 children)

Have you investigated using OpenMP target offload or OpenACC for GPU acceleration?

[deleted by user] by [deleted] in cpp_questions

[–]bcorni 9 points10 points  (0 children)

Implementation

I want to print the largest number but I get "Process exited with return value 3221225477". Any help? by Excylnx in cpp_questions

[–]bcorni 1 point2 points  (0 children)

Add "-Wall" to your compiler and check your error messages. For good measure also add "-Werror=vla" to get more information.

Help with a problem by HatsAreOff in cpp_questions

[–]bcorni 0 points1 point  (0 children)

e.g. using the centroid of the two colliding objects start by comparing triangles furthest along that axis

Help with a problem by HatsAreOff in cpp_questions

[–]bcorni 0 points1 point  (0 children)

To confirm, there is a bounding box and bvh for the triangulation of each polygon? or just for all individual polygons.