Noutați

MSVC ARM64 optimizations in Visual Studio 2022 17.8 

MSVC ARM64 optimizations in Visual Studio 2022 17.8  Jiong Wang (ARM Ltd) Hongyon Suauthai (ARM) January 9th, 20240 1 Visual Studio 2022 17.8 has been released recently (download it here). While there is already a blog “Visual Studio 17.8 now available!” covering new features and improvements, we would like to share more information with you about what is new for the MSVC ARM64 backend in this blog. In the last couple of months, we have been improving code-generation for the auto-vectorizer so that it can generate Neon instructions for more cases. Also, we have optimized instruction selection for a few scalar code-generation scenarios, for example short circuit evaluation, comparison against immediate, and smarter immediate split for logic instruction. Auto-Vectorizer supports conversions between floating-point and integer The following conversions between floating-point and integer types are common in real-world code. Now, they are all enabled in the ARM64 backend and hooked up with the auto-vectorizer. From To Instruction double float fcvtn double int64_t fcvtzs double uint64_t fcvtzu float double fcvtl float int32_t fcvtzs float uint32_t fcvtzu int64_t double scvtf uint64_t double ucvtf int32_t float scvtf uint32_t float ucvtf For example: void test (double * __restrict a, unsigned long long * __restrict b) { for (int i = 0; i < 2; i++) { a[i] = (double)b[i]; } } In Visual Studio 2022 17.7, the code-generation was the following in which both the computing throughput and load/store bandwidth utilization were suboptimal due to scalar instructions being used. ldp x9, x8, [x1] ucvtf d17, x9 ucvtf d16, x8 stp d17, d16, [x0] In Visual Studio 2022 17.8.2, the code-generation has been optimized into: ldr q16,[x1] ucvtf v16.2d,v16.2d str q16,[x0] A single pair of Q register load & store plus SIMD instructions are used now. The above example is a conversion between double and 64-bit integer, so both types are the same size. There was another issue in the ARM64 backend preventing auto-vectorization on conversion between different sized types and it has been fixed as well. MSVC also auto-vectorizes the following example now: void test_df_to_sf (float * __restrict a, double * __restrict b, int * __restrict c) { for (int i = 0; i < 4; i++) { a[i] = (float) b[i]; c[i] = ((int)a[i])

Read More

Best of 2023: Copilots For Everyone: Microsoft Brings Copilots to the Masses

As we close out 2023, we at DevOps.com wanted to highlight the most popular articles of the year. Following is the latest in our series of the Best of 2023. Microsoft has been doing a lot to extend the coding ‘copilot’ concept into new areas. And at its Build 2023 conference, Microsoft leadership unveiled new capabilities in Azure AI Studio that will empower individual developers to create copilots of their own. This news is exciting, as it will enable engineers to craft copilots that are more knowledgeable about specific domains. Below, we’ll cover some of the major points from the Microsoft Build keynote from Tuesday, May 23, 2023, and explore what the announcement means for developers. We’ll examine the copilot stack and consider why you might want to build copilots of your own. What is Copilot? A copilot is an artificial intelligence tool that assists you with cognitive tasks. To date, the idea of a copilot has been mostly associated with GitHub Copilot, which debuted in late 2021 to bring real-time auto-suggestions right into your code editor. “GitHub Copilot was the first solution that we built using the new transformational large language models developed by OpenAI, and Copilot provides an AI pair programmer that works with all popular programming languages and dramatically accelerates your productivity,” said Scott Guthrie, executive vice president at Microsoft. However, Microsoft recently launched Copilot X, powered by GPT-4 models. A newer feature also offers chat functionality with GitHub Copilot Chat to accept prompts in natural language. But the Copilot craze hasn’t stopped there—Microsoft is actively integrating Copilot into other areas, like Windows and even Microsoft 365. This means end users can write natural language prompts to spin up documents across the Microsoft suite of Word, Teams, PowerPoint and other applications. Microsoft has also built Dynamics 365 Copilot, Power Platform Copilot, Security Copilot, Nuance and Bing. With this momentum, it’s easy to imagine copilots for many other development environments. Having built out these copilots, Microsoft began to see commonalities between them. This led to the creation of a common framework for copilot construction built on Azure AI. At Build, Microsoft unveiled how developers can use this framework to build out their own copilots. Building Your Own Copilot Foundational AI models are powerful, but they can’t do everything. One limitation is that they often lack access to real-time context and private data. One way to get around this is by extending models through plugins with REST API endpoints to grab context for the tasks at hand. With Azure, this could be accomplished by building a ChatGPT plugin inside VS Code and GitHub Codespaces to help connect apps and data to AI. But you can also take this further by creating copilots of your own and even leveraging bespoke LLMs. Understanding The Azure Copilot Stack Part of the Azure OpenAI service is the new Azure AI Studio. This service enables developers to combine AI models like ChatGPT and GPT-4 with their own data. This could be used to build copilot experiences that are more intelligent and contextually aware. Users can tap into an open source LLM, Azure OpenAI or bring their own AI model. The next step is creating a “meta-prompt” that provides a role for how the copilot should function. So, what’s the process like? Well, first, you […]

Read More

Everything You Need To Know About The Copy Assignment Operator In C++ Classes

Classes and Objects are part of object-oriented methods and typically provide features such as properties and methods. One of the great features of an object orientated language like C++ is a copy assignment operator that is used with operator= to create a new object from an existing one. In this post, we explain what a copy assignment operator is and its types in usage with some C++ examples. What is a copy assignment operator in C++? The Copy Assignment Operator in a class is a non-template non-static member function that is declared with the operator=. When you create a class or a type that is copy assignable (that you can copy with the = operator symbol), it must have a public copy assignment operator. Here is a simple syntax for the typical declaration of a copy assignment operator which is defaulted: Syntax (Since C++11).   class_name & class_name :: operator= ( const class_name& ) = default;   Here is an example in a class.   Tmyclass& operator=(const Tmyclass& other) = default; // Copy Assignment Operator   Is there a simple example of using the copy assignment operator in C++? The forced copy assignment operator is default in any class declarations. This means you don’t need to declare it as above. Let’s give examples without using it. Let’s give a simple C++ example to copy assignment operator with default option, here is a simple class:   class myclass {   public:   std::string str;   };   Because this is default in any class declaration, and it is automatically declared. This class is same as below.   class myclass {   public:   std::string str;     Tmyclass& operator=(const Tmyclass& other) = default; // Copy Assignment Operator };   And here is how you can use this “=” copy assignment operator with both class examples above.   Tmyclass o1, o2;   o2 = o1; // Using Copy Assignment Operator   now let’s see different usage types in C++, 1. Typical Declaration of A Copy Assignment Operator with Swap 2. Typical Declaration of A Copy Assignment Operator ( No Swap) 3. Forced Copy Assignment Operator 4. Avoiding Implicit Copy Assignment 5. Implicitly-declared copy assignment operator 6. Deleted implicitly declared copy assignment operator 7. Trivial copy assignment operator 8. Eligible copy assignment operator 9. Implicitly-defined copy assignment operator C++ Builder is the easiest and fastest C and C++ compiler and IDE for building simple or professional applications on the Windows operating system. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for UIs. There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.

Read More

Skillsoft Survey Sees AI Driving Increased Need to Retrain IT Teams

More organizations than ever will need to invest in IT training as advances in artificial intelligence (AI) transform roles and responsibilities in the coming year. A survey of 2,740 IT decision-makers conducted by Skillsoft, a provider of an online training platform, finds two-thirds (66%) were already dealing with skills gaps in 2023. As AI becomes more pervasively applied to the management of IT, that skills gap is only going to widen given the limited pool of IT professionals that have any experience using AI to manage IT. Skillsoft CIO Orla Daly said it’s already apparent AI creates an imperative for training because there are simply not enough IT people with the requisite skills required. In fact, the survey finds nearly half of IT decision-makers (45%) plan to close skills gaps by training their existing teams. That training is crucial because the primary reason IT staff change jobs is a lack of growth and development opportunities, noted Daly. While there is naturally a lot of consternation over the potential elimination of IT jobs, in the final analysis, AI will add more different types of jobs than it eliminates, adds Daly. Each of those jobs will require new skills that will need to be acquired and honed, she notes. “Training is the price of innovation,” said Daly. In the meantime, there is much interest in finding ways to automate existing IT processes to create more time for IT teams to experiment with AI technologies, said Daly. The report also finds well over half of IT decision-makers (56%) expect their IT budgets to increase to help pay for new platforms and tools, compared with only 12% expecting a decrease. It’s not clear to what degree AI will transform the management of AI, but it’s already apparent that many manual tasks involving, for example, generating reports are about to be automated. The instant summarization capabilities that generative AI enables also promise to dramatically reduce the time required to onboard new members to an incident response team. Rather than having to allocate someone on the team to bring new members up to speed, each new member of the team will use queries framed in natural language to determine for themselves the extent of the crisis at hand. In addition, many tasks that today require expensive specialists to perform might become more accessible to a wider range of organizations as, for example, more DevOps processes are automated. That doesn’t necessarily mean that DevOps as an IT discipline disappears as much as it leads to the democratization of best DevOps practices. Each IT organization in the year ahead will need to determine to what degree to rely on AI to manage IT processes. It may take a while before IT teams have enough confidence in AI to rely on it to manage mission-critical applications but many of the tasks that today conspire to make the management of IT tedious will undoubtedly fade away. The challenge and the opportunity now is identify those tasks today with an eye toward revamping how IT might be managed in the age of AI tomorrow.

Read More

What Is The New Optional Class Template In C++ 17?

The C++17 standard came with a lot of great features and std::optional was one of the main features of today’s modern C++. std::optional is a class template that is defined in the header and represents either a T value or no value. In this post, we explain, what is optional in modern C++ and how we can use it efficiently. What is the optional class template in C++ 17 and beyond? The std::optional feature is a class template that is defined in the header and represents either a T value or no value (which is signified by the tag type nullopt_t). In some respects, this can be thought of as equivalent to variant, but with a purpose-built interface. Here is the definition of the std::optional class template.   template class optional;   Optional can be used to define any type of variables as below.   std::optional a(5); std::optional b;   An optional variable can be checked by has_value() method if it has a value or not.   if (a.has_value()) { }   Here is another example that has a function with an optional return.   std::optional testopt(std::string s) { if(s.length()==0) return {}; else return s; }   as you see our function may return a string as an option or it may have no return value. A common use case for optional is the return value of a function that may fail. Any instance of optional at any given point in time either contains a value or does not contain a value. If an optionalcontains a value, the value is guaranteed to be allocated as part of the optional object footprint, i.e. no dynamic memory allocation ever takes place. Thus, an optional object models an object, not a pointer, even though operator*() and operator->() are defined. Is there a simple example about the optional class template in C++ 17? Here is a simple example about the std::optional, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19   #include #include   int main() { std::optional a(5);  // a = 5 std::optional b;   // b has no value   if (a.has_value())         { int z = a.value() + b.value_or(0); std::cout

Read More

Three Important C++ 17 Posts That Can Be Used In 2024

Happy New Year Developers! We wish you a great new year that brings peace, happiness, health, and success to you and your family. This week, we have 3 more Modern C++ features that can be used in C++ Builder. The contents of the Parallelism Technical Specification are added to C++17, and as a result, make their way into many C++ compilers and IDEs, such as the latest C++ Builder 12. We explain this feature that adds new overloads, taking an additional execution policy argument, to many algorithms, as well as entirely new algorithms. The Parallelism Technical Specification adds several new algorithms to the modern C++ and in the next post, we explain the new algorithms that come with C++17. Another feature in C++17 was basic_string_view (std::basic_string_view) which is a constant string container that can be used for multiple string declarations, and we explain basic_string_view and its types in another post. Our educational LearnCPlusPlus.org site has a broad selection of new and unique posts with examples suitable for everyone from beginners to professionals alike. It is growing well thanks to you, and we have many new readers, thanks to your support! The site features a treasure-trove of posts that are great for learning the features of modern C++ compilers with very simple explanations and examples. RAD Studio’s C++ Builder, Delphi, and their free community editions C++ Builder CE, and Delphi CE are powerful tools for modern application development. Table of Contents Where I can I learn C++ and test these examples with a free C++ compiler? How to use modern C++ with C++ Builder? How to learn modern C++ for free using C++ Builder? Do you want to know some news about C++ Builder 12? Where I can I learn C++ and test these examples with a free C++ compiler? If you don’t know anything about C++ or the C++ Builder IDE, don’t worry, we have a lot of great, easy to understand examples on the LearnCPlusPlus.org website and they’re all completely free. Just visit this site and copy and paste any examples there into a new Console, VCL, or FMX project, depending on the type of post. We keep adding more C and C++ posts with sample code. In today’s round-up of recent posts on LearnCPlusPlus.org, we have new articles with very simple examples that can be used with: The free version of C++ Builder 11 CE Community Edition or a professional version of C++ Builder or free BCC32C C++ Compiler and BCC32X C++ Compiler or the free Dev-C++ Read the FAQ notes on the CE license and then simply fill out the form to download C++ Builder 11 CE. How to use modern C++ with C++ Builder? With the C++17 standard, the contents of the Parallelism Technical Specification are added to modern C++, and as a result, make their way into many C++ compilers and IDEs, such as the latest C++ Builder 12. This feature adds new overloads, taking an additional execution policy argument, to many algorithms, as well as entirely new algorithms. Three execution policies are supported, which respectively provide sequential, parallel, and vectorized execution. In the first post, we explain what are the Parallelism Features that come with C++ 17 The Parallelism Technical Specification adds several new algorithms to the modern C++. These are modernized in the  header in the standard library. In the next post, we explain the new algorithms that come with C++17. […]

Read More

Best of 2023: Microservices Sucks — Amazon Goes Back to Basics

As we close out 2023, we at DevOps.com wanted to highlight the most popular articles of the year. Following is the latest in our series of the Best of 2023. Welcome to The Long View—where we peruse the news of the week and strip it to the essentials. Let’s work out what really matters. This week: Amazon Prime Video has ditched its use of microservices-cum-serverless, reverting to a traditional, monolithic architecture. It vastly improved the workload’s cost and scalability. I’m Shocked. Shocked. Analysis: But it depends what you mean by “monolithic” None of this is a surprise to us old-skool devs. Although the team did need to clone the monolith a few times, splitting up the tasks so as to retain enough scaling headroom. But it shouldn’t be at all shocking—unless you’ve drunk the µservices Kool-Aid. What’s the story? Joab Jackson reports—“Return of the Monolith”: “Hopelessly archaic”The engineering team at Amazon Prime Video has been roiling the cloud native computing community with its explanation that … a monolithic architecture has produced superior performance over a microservices- and serverless-led approach. … Shocking!…In theory, the use of serverless would allow the team to scale each service independently. It turned out … they hit a hard scaling limit at only 5%. … Initially, the team tried to optimize individual components, but this did not bring about significant improvements. So, the team moved all the components into a single process, hosting them on … EC2 and … ECS.…The IT world is nothing but cyclical, where an architectural trend is derided as hopelessly archaic one year [and] the new hot thing the following year. Certainly, over the past decade when microservices ruled—and the decade before when web services did—we’ve heard more than one joke … about “monoliths being the next big thing.” Now it may actually come to pass. Not just a scaling advantage? Rafal Gancarz also notes huge cost savings—“Prime Video Switched from Serverless to EC2 and ECS”: “Single application process”Prime Video, Amazon’s video streaming service … achieved a 90% reduction in operational costs as a result. … The initial architecture of the solution was based on microservices … implemented on top of the serverless infrastructure stack. The microservices included splitting audio/video streams into video frames or decrypted audio buffers as well as detecting various stream defects … using machine-learning algorithms.…The problem of high operational cost was caused by a high volume of read/writes to the S3 bucket storing intermediate work items … and a large number of step function state transitions. … In the end, the team decided to consolidate all of the business logic in a single application process. … The resulting architecture had the entire … process running [as] instances distributed across different ECS tasks to avoid hitting vertical scaling limits. Horse’s mouth? Marcin Kolny, a Prime Video dev—“The move from a distributed microservices architecture to a monolith application helped achieve higher scale, resilience, and reduce costs”: “Also simplified the orchestration”We took a step back and revisited the architecture. … The main scaling bottleneck in the architecture was the orchestration management that was implemented using AWS Step Functions. Our service performed multiple state transitions for every second of the stream.…We realized that distributed approach wasn’t bringing a lot of benefits in our specific use case, so … we moved all components into a single process to keep the data transfer within the process memory, which also simplified the orchestration logic. [Then] we cloned […]

Read More

What Is basic_string_view And string_view In Modern C++

C++17 had enormous changes in C++ features. One of them was basic_string_view (std::basic_string_view) which is a constant string container that can be used for multiple string declarations. The basic_string_view is a modern way of read-only text definition. It can be used by iterators and other methods of the basic_string_view class. In this post, we explain basic_string_view and its types. What is basic_string_view in modern C++ In the Library Fundamentals Technical Specification (LFTS), The C++ commitee introduced std::basic_string_view, and it was approved for C++17. The basic_string_view (std::basic_string_view) is a class template defined in the header that is used to define a constant string container that can be used to define multiple strings which refers to the contiguous character sequence, and the first element of this sequence position at the zero position. The basic_string_view is a modern way of read-only text definition, it can be used by iterators, and other methods of the basic_string_view class can be used.  Here is the syntax of the basic_string_view:   template class basic_string_view;   We can use different character types in std::basic_string_view types as same as std::basic_string. The std::basic_string_view has 5 different string types, these are, std::string_view, std::wstring_view, std::u8string_view, std::u16string_view, and std::u32string_view. The std::string_view provides read-only access to a string definition with chars as similar to the interface of std::string. In addition to this, we can use std::wstring_view, std::u16string_view, and std::u32string_view in C++17. There is std::u8string_view that is added by the C++20 standards too. Here are the basic_string_types and their features. Type Char Type Definition Standard std::string_view char std::basic_string_view (C++17) std::wstring_view wchar_t std::basic_string_view (C++17) std::u8string_view char8_t std::basic_string_view (C++20) std::u16string_view char16_t std::basic_string_view (C++17) std::u32string_view char32_t std::basic_string_view (C++17) Is there an example about basic_string_view in modern C++ Here is a C++ example that we use std::string_view, std::wsting_view, std::u16string_view, std::u32string_view in C++17. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30   #include #include #include   int main() { const std::string_view  sview = “This is a stringview example”; const std::wstring_view wsview = L“This is a stringview example”; const std::u16string_view u16sview = u“This is a stringview example”; const std::u32string_view u32sview = U“This is a stringview example”;   const std::string_view sviews[]{ “This is “, “LearnCPlusPlus.org “, “and welcome “, “!” };   for ( auto sv : sviews) { std::cout

Read More

Eigen C++ Template Library with C++Builder and VCL

This post describes how to using the Eigen C++ Template Library with C++ Builder and VCL. What is the Eigen C++ Template Library? Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.  A Gentle Introduction to Linear Algebra is here.   Eigen doesn’t have any dependencies other than the C++ standard library.  Eigen consists only of header files, so there is nothing to compile before you can use it.  There is no binary library to link to, and no configured header file. Eigen is a pure template library defined in the headers. What is Linear algebra?  Linear algebra is the study of lines and planes, vector spaces and mappings that are required for linear transforms. It is a relatively young field of study, having initially been formalized in the 1800s in order to find unknowns in systems of linear equations. A linear equation is just a series of terms and mathematical operations where some terms are unknown; for example: y = 4 * x + 1 Equations like this are linear in that they describe a line on a two-dimensional graph. The line comes from plugging in different values into the unknown x to find out what the equation or model does to the value of y. Eigen’s source code: In order to use Eigen, you just need to download and extract Eigen’s source code from here.  The header files in the Eigen subdirectory are the only files required to compile programs using Eigen. The header files are the same for all platforms. It is not necessary to use CMake or install anything! How to use the Eigen Library with C++ Builder?  Download and extract Eigen’s source code from here. Add your Eigen Source Folder to your C++ Builder Include and Library Paths.  In my case, my Eigen Source Folder is: C:/Users/amannarino/Documents/Eigen3/Eigen In C++ Builder, use Tools | Options | Language | C++ | Paths and Directories     4. In my sample C++ Builder VCL application, in my MainUnit.cpp file, I added the Eigen header files I wanted to use to test, for example, the member functions for the MatrixXd and IOFormat types, to try the Eigen Getting Started example from here: https://eigen.tuxfamily.org/dox/GettingStarted.html 5. This is the first Eigen sample program we will try to build and run using C++ Builder 12: C++ #include #include using Eigen::MatrixXd; int main() { MatrixXd m(2,2); m(0,0) = 3; m(1,0) = 2.5; m(0,1) = -1; m(1,1) = m(1,0) + m(0,1); std::cout Lines->Text = ConvertToString(m).c_str(); } 9.Build and Run the application.  Click on the Using Eigen/Dense button, and you will see the Matrix Output, like this: Congratulations!  You now know how to using the Eigen C++ Template Library with C++ Builder and VCL. If you are interetsed in learning more on what you can do with the Eigen C++ Template Library with C++ Builder and VCL, it’s worth taking the time to read this long tutorial on The Matrix class (Dense matrix and array manipulation). You can try using the Eigen C++ Template Library with C++ Builder and VCL by downloading and installing the free 30 day trial of the current C++ Builder 12 from here! Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy. Start Free Trial   Upgrade Today    Free […]

Read More

Best of 2023: Will ChatGPT Replace Developers?

As we close out 2023, we at DevOps.com wanted to highlight the most popular articles of the year. Following is the latest in our series of the Best of 2023. AI is buzzing again thanks to the recent release of ChatGPT, a natural language chatbot that people are using to write emails, poems, song lyrics and college essays. Early adopters have even used it to write Python code, as well as to reverse engineer shellcode and rewrite it in C. ChatGPT has sparked hope among people eager for the arrival of practical applications of AI, but it also begs the question of whether it will displace writers and developers in the same way robots and computers have replaced some cashiers, assembly-line workers and, perhaps in the future, taxi drivers.  It’s hard to say how sophisticated the AI text-creation capabilities will be in the future as the technology ingests more and more examples of our online writing. But I see it having very limited capabilities for programming. If anything, it could end up being just another tool in the developer’s kit to handle tasks that don’t take the critical thinking skills software engineers bring to the table. ChatGPT has impressed a lot of people because it does a good job of simulating human conversation and sounding knowledgeable. Developed by OpenAI, the creator of the popular text-to-image AI engine DALL-E, it is powered by a large language model trained on voluminous amounts of text scraped from the internet, including code repositories. It uses algorithms to analyze the text and humans fine-tune the training of the system to respond to user questions with full sentences that sound like they were written by a human. But ChatGPT has flaws—and the same limitations that hamper its use for writing content also render it unreliable for creating code. Because it’s based on data, not human intelligence, its sentences can sound coherent but fail to provide critically informed responses. It also repurposes offensive content like hate speech. Answers may sound reasonable but can be highly inaccurate. For example, when asked which of two numbers, 1,000 and 1,062, was larger, ChatGPT will confidently respond with a fully reasoned response that 1,000 is larger. OpenAI’s website provides an example of using ChatGPT to help debug code. The responses are generated from prior code and lack the capability to replicate human-based QA, which means it can generate code that has errors and bugs. OpenAI acknowledged that ChatGPT “sometimes writes plausible-sounding but incorrect or nonsensical answers.” This is why it should not be used directly in the production of any programs. The lack of reliability is already creating problems for the developer community. Stack Overflow, a question-and-answer website coders use to write and troubleshoot code, temporarily banned its use, saying there was such a huge volume of responses generated by ChatGPT that it couldn’t keep up with quality control, which is done by humans. “​​Overall, because the average rate of getting correct answers from ChatGPT is too low, the posting of answers created by ChatGPT is substantially harmful to the site and to users who are asking or looking for correct answers.” Coding errors aside, because ChatGPT—like all machine learning tools—is trained on data that suits its outcome (in this case, a textual nature), it lacks the ability to understand the […]

Read More