Tag: lambdas

Personal Log – Where No Init Has Gone Before in C++ – Andrei Zissu – CppCon 2022

  • Lobby
  • Tag Archives: lambdas

https://cppcon.digital-medium.co.uk/tag/cppcon/">cppcon.org/
---

Personal Log - Where No Init Has Gone Before in C++ - Andrei Zissu - CppCon 2022
https://github.com/CppCon/CppCon2022

Can your code have logging entries whose sensitive messages don't show up in the shipped binaries? And can the following code snippet ever work?

static bool initially_false = false;
void no_one_calls_me() { DO_ON_INIT(initially_false = true); }
int main() {assert(initially_false == true); return 0;}

Well yes, this is actual working C++17 code! And yes, we can use this tool to produce a logger with vanishing strings!

As part of this talk we will go behind the scenes of the DO_ON_INIT utility, the process involved in developing the idea and its surprisingly simple implementation details (under 20 lines of C++17 code, and even less in C++20).

We shall also see how this utility is instrumental in making possible the no-strings-attached logger and its associated automatically-generated decoding facility. We will implement a simple obfuscation technique which replaces logged strings with hashes at compile-time, to avoid shipping binaries containing sensitive textual giveaways. To decode such logs (in a separate decoder utility) we shall use DO_ON_INIT to automatically collect and register all the logged strings system-wide, along with their hashes, without requiring any additional tool (such as an in-house pre-processor).

This is yet another example of emergent behavior in C++, consisting of unrelated language features being put to use together in a novel and unexpected way. Could your idea be next?
---

Andrei Zissu

Andrei Zissu is an experienced cross-industry C++ developer, notably having worked on low-level reverse engineering systems employing API hooking, DLL injection and other advanced techniques. In early 2022 he joined the WG21 standards committee as a member of the Israeli NB, and is planning to explore the exciting realm of reflection.

Andrei is currently employed at Binah.ai, an Israeli startup developing ground breaking AI-based remote health monitoring technology. The feature presented in this talk has been developed by him in recent months for the Binah.ai C++17 codebase, and is being gradually staged into production code.

Andrei loves the occasional opportunity to explore the rough edges of C++. The latest such opportunity along with its discoveries will be presented in this talk.
---

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
YouTube Channel Managed by Digital Medium Ltd https://events.digital-medium.co.uk

#cppcon.digital-medium.co.uk/tag/cppcon/">cppcon #cppcon.digital-medium.co.uk/tag/programming/">programming #cpp

Filed under: UncategorizedTagged with: , , , , ,

Fast C++ by using SIMD Types with Generic Lambdas and Filters – Andrew Drakeford – CppCon 2022

  • Lobby
  • Tag Archives: lambdas

https://cppcon.digital-medium.co.uk/tag/cppcon/">cppcon.org/
---

Fast C++ by using SIMD Types with Generic Lambdas and Filters - Andrew Drakeford - CppCon 2022
https://github.com/CppCon/CppCon2022

We show that very high-performance code can be generated when generic lambdas are instantiated with vectorized numeric types ( SIMD wrappers ). Trivial lambdas can be used to create STL-like functionality but with a performance as high as 10-20 G Flops which is competitive with the standard libraries and some commercial libraries. A small framework that supports memory management, alignment and padding of vectors is used to support this style of cppcon.digital-medium.co.uk/tag/programming/">programming. It applies users’ lambdas and filters over vector-like objects.

The performance of trivial implementations of some STL-like functions, memcopy , inner_product , sum of squared values, max_element, and accumulate ( with error correction) is investigated. In some cases, the STL generates scalar instructions and performs quite poorly when compared with the lambda generated code which is branchless and makes full use of the SIMD instructions.

Branching can be a problem for vectorized code. We explore cases where the branches have light, medium, and heavy calculation loads and different frequencies of being traversed. With frequent branching, we find that select operations are useful for handling conditional constants. This is also true for conditionals with lightweight and middleweight expressions in their branches. Our compound operation, transformSelect computes both branches and conditionally blends the in-register results appears to be quite a useful tool.

When heavy branches are traversed infrequently, we can filter to a value-based contiguous view and then perform a transform efficiently using vectorized instructions (filterTransform). In the limiting case where all branches have very heavy compute when compared to the cost of filtering, it is best to filter the cases to separate contiguous regions of memory and then apply the vectorized algorithms so that all the registers lanes can be used in the calculation.

We illustrate this with an example of writing a vectorized version of the inverse cumulative normal distribution function. We use VC++, Intel 2022, and clang compilers and compare the performance of different implementation approaches on silver and gold/W Xeons with the same function in Intel’s short vector math library (SVML).
---

Andrew Drakeford

A Physics PhD who started developing C++ applications in the early 90's at British Telecom labs. For the last two decades he has worked in finance developing calculation libraries and trading systems in C++.
---

Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

#cppcon.digital-medium.co.uk/tag/cppcon/">cppcon #cppcon.digital-medium.co.uk/tag/programming/">programming #cpp

Filed under: UncategorizedTagged with: , , , ,

C++ Lambda Idioms – by Timur Doumler – CppCon 2022

  • Lobby
  • Tag Archives: lambdas

https://cppcon.org/
---

C++ Lambda Idioms - Timur Doumler - CppCon 2022
https://github.com/CppCon/CppCon2022

Ever since they were introduced in C++11, lambdas have been an essential language feature. Each subsequent standard added more functionality: we got generic lambdas and init captures in C++14, constexpr lambdas in C++17, default-construction and assignment, explicit template arguments and more in C++20, and even more possibilities are coming in the upcoming C++23 standard.

In this talk, we are looking at various interesting things you can do with lambdas. Some of these are well-established, useful idioms; others are lesser known, surprising tricks. Have you ever inherited from a lambda? Can you think of three different ways to call a lambda recursively? Do you know what happens if we assign an immediately-invoked lambda expression to a static variable? If not, then this talk is for you.
---

Timur Doumler

Timur Doumler is the Developer Advocate for C++ tools at JetBrains and an active member of the ISO C++ standard committee. As a developer, he worked many years in the audio and music technology industry and co-founded the music tech startup Cradle. Timur is passionate about building inclusive communities, clean code, good tools, low latency, and the evolution of the C++ language.
__

Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
YouTube Channel Managed by Digital Medium Ltd https://events.digital-medium.co.uk

#cppcon #programming #lambda

Filed under: UncategorizedTagged with: , , , , , ,