Hidden Overhead of a Function API
designed ones!When talking about performance, we typically think about the function logic. We’ll see that a well designed function API can have an even larger impact.How will we compare performance? ● they might be, and often are, totally irrelevant to speed. 17 Credit to Khalil Estell: Firefox function distribution 157946 functions above (127B) 167404 functions below (127B)Understanding how machine problems? Pros: ● Default constructor before the function call is avoided 36Does it solve our problems? Pros: ● Default constructor before the function call is avoided Cons (unless we fully trust the0 码力 | 158 页 | 2.46 MB | 5 月前3Back to Basics - Function Call Resolution
Back to Basics - Function Call Resolution Copyright © 2024 by Ben Saks and Dan Saks Back to Basics: Function Call Resolution by Ben Saks and Dan Saks September, 2024 1 Saks & Associates These notes +1-412-521-4117 (voice) service@saksandassociates.com saksandassociates.com 2Back to Basics - Function Call Resolution Copyright © 2024 by Ben Saks and Dan Saks About Ben Saks Ben Saks is the chief Ben earned a B.A. with Distinction in Computer Science from Carleton College. 4Back to Basics - Function Call Resolution Copyright © 2024 by Ben Saks and Dan Saks About Dan Saks Dan Saks is the president0 码力 | 44 页 | 1.30 MB | 5 月前3Limitations and Problems in std::function and Similar
Limitations and Problems in std::function and similar constructs Amandeep Chawla | Sr. Computer Scientist II amandeep@adobe.com | adchawla@gmail.com Image by Bruno Tornielli© 2024 Adobe. All Rights we can control. ▪ std::function© 2024 Adobe. All Rights Reserved. Adobe Confidential. Task Based Mechanism© 2024 Adobe. All Rights Reserved. Adobe Confidential. std::function ▪ Is a class template ▪ It is a general-purpose polymorphic function wrapper ▪ Instances of std::function can store, copy, and invoke any CopyConstructible Callable target ▪ Uses type-erasure under the hood to gain all the0 码力 | 62 页 | 3.57 MB | 5 月前3Calling Functions A Tutorial
SFINAE Overload Resolution (Viable) Candidate Functions Ranking Ambiguous Function Calls Access Labels Function Template Specializations Virtual Dispatch Deleting FunctionsContent 4 Overview SFINAE Overload Resolution (Viable) Candidate Functions Ranking Ambiguous Function Calls Access Labels Function Template Specializations Virtual Dispatch Deleting FunctionsDisclaimer 5 This Argument Deduction Name Lookup Template Argument Deduction For all candidate function templates, deduce all function template parameters based on the given template arguments. and add them to the0 码力 | 111 页 | 5.11 MB | 5 月前3Bridging the Gap: Writing Portable Programs for CPU and GPU
Conditional function body constexpr everything Disable Cuda warnings host device template 3 The dark path Function dispatch triple 4 Cuda proposal Conditional host device Forbid bad cross function calls Cuda proposal Thank you Allowed function calls in Cuda CPU host GPU global device9/66 Motivation Patterns The dark path Cuda proposal Thank you Allowed function calls in Cuda CPU host GPU global Quiz time12/66 Motivation Patterns The dark path Cuda proposal Thank you Quiz time: Bad cross function calls � � 1 struct H { __host__ int func() { return 42; } }; 2 3 struct D { __device__ int func()0 码力 | 124 页 | 4.10 MB | 5 月前3C++ Exceptions for Smaller Firmware
○ N = number of checked function calls 86My Hypothesis ● Cost of using result types: S(N) = aN ○ a = average cost of a check per call ○ N = number of checked function calls ● Cost of using exception: using result types: S(N) = aN ○ a = average cost of a check per call ○ N = number of checked function calls ● Cost of using exception: S(M) = bM + E ○ b = average cost of exception metadata ○ M = number Functions ❌ Calls other functions ❌ Contains destructors ❌ try/catchThe 3 types of functions 100 ������ Leaf Functions ������ Transparent-Trivial Functions ������ Reentrant Functions ❌ Calls other functions0 码力 | 237 页 | 6.74 MB | 5 月前3Contracts for C++
(w: w.index() == i); // postcondition assertion Proposal: add contract assertions to C++ Function contract assertions5 Copyright (c) Timur Doumler | @timur_audio | https://timur.audio arguments and/or program state when a function is called. Obligation of caller (client) postcondition = Condition on return value and/or program state when a function returns. Obligation of callee (implementer)30 audio • Precondition assertions (pre): after the initialisation of function parameters, before the evaluation of the function body • Postcondition assertions (post): after the result object value0 码力 | 181 页 | 4.44 MB | 5 月前3How to Build Your First C++ Automated Refactoring Tool - CppCon 2023
Matcher Reference 56AST Matchers - Matcher Expressions Looking for calls to a member function on a class named A and whose called function is named foo and whose first parameter is an integer. 57 cxxMemberCallExpr( hasType(isInteger())))))AST Matchers - Matcher Expressions Looking for calls to a member function on a class named A and whose called function is named foo and whose first parameter is an integer. 58 cxxMemberCallExpr( hasType(isInteger())))))AST Matchers - Matcher Expressions Looking for calls to a member function on a class named A and whose called function is named foo and whose first parameter is an integer. 59 cxxMemberCallExpr(0 码力 | 83 页 | 6.03 MB | 5 月前3Back to Basics Concepts
com 3 C++ Concepts, Constraints, and Requirements C++20 ©2024 by josuttis.com 4 C++ Generic Function to Insert a Value templatevoid add(CollT& coll, const T& val) { coll C++98 Nico Josuttis C++ Concepts @cppcon 2024-09-18 2©2024 by josuttis.com 5 C++ Overloading Function Templates template void add(CollT& coll, const T& val) { coll.push_back(val); std::set coll2; add(coll1, 42); add(coll2, 42); Overload resolution prefers more specialized function C++20 Constraints formulated by a requires clause Requirements with requires expression Concept 0 码力 | 23 页 | 2.14 MB | 5 月前3Back To Basics Functions
functions! We'll start with a basic function example, identifying the function signature and basic abilities of a function. Then we are going to view this function again from the perspective of assembly assembly (using compiler explorer) to show you how a function is structured. From the assembly view, we will then observe that functions have addresses (they must after all!) and that we can store functions pointers. We'll take a brief aside to show you how modern C++ also gives us the convenient std::function. Functions need not always be 'global' building blocks of our programs, the next step in our journey0 码力 | 123 页 | 7.26 MB | 5 月前3
共 337 条
- 1
- 2
- 3
- 4
- 5
- 6
- 34