[AI]: My First Date With IA... MMX & SSE Optimization... Now AVX :P

Published on 28 January 2025 at 05:50

Public repository of public code on GitHub for the initial implementation tests of the Perceptron in C++. Soon, I will make more commits with the implementation reduced to C. Afterwards, I will explore libraries, frameworks, and tools in C/C++ for AI development, and look for optimization possibilities using AVX, MMX, SSE, SIMD, etc., with NASM, MASM, and/or C Inline Assembly.

Project IA-Perceptron

ASM Lessons FFMPEG

My Two Date Inna Day

Optimizing Perceptron Performance through: Code Conversion & Advanced Optimization Techniques

Haz clic aquí para añadir texto

This research PoC focuses on optimizing the performance of a Perceptron model implemented in C++. The main objective is to achieve significant improvements in execution speed and model efficiency through code conversion and the application of low-level optimization techniques.

Conversion to C and Exploitation of SIMD Instructions

The first stage of optimization involves converting the source code from C++ to C. This conversion facilitates the implementation of SIMD (Single Instruction, Multiple Data) instructions, such as those provided by the AVX, SSE, and MMX extensions. These extensions allow parallel operations on multiple data simultaneously, which can result in a considerable increase in performance, especially in tasks involving vector or matrix operations, such as those found in the Perceptron algorithm.

Code Analysis and Selection of Optimization Techniques

A comprehensive analysis of the Perceptron code will be performed to identify bottlenecks and areas susceptible to optimization. This analysis will include the identification of critical loops, CPU-intensive operations, and memory access patterns that can be improved by applying optimization techniques such as:

  • Vectorization: Utilizing SIMD instructions to parallelize operations.
  • Loop unrolling: Reducing loop iteration overhead by replicating the loop body.
  • Memory access optimization: Improving data locality and minimizing memory accesses.
  • Dead code elimination: Removing code that does not contribute to the final result.

Integration of Optimizations and Performance Evaluation:

The selected optimization techniques will be carefully integrated into the Perceptron code. Profiling and benchmarking tools will be used to measure the impact of each optimization on the model's performance. Special attention will be paid to reducing execution time, optimizing memory usage, and energy efficiency.

Inspiration from ffmpeg

The project will draw inspiration from optimization examples extracted from ffmpeg, a software library widely recognized for its high performance and extensive use of low-level optimization techniques. The optimization strategies employed in ffmpeg will be analyzed to identify best practices and adapt them to the context of the Perceptron.

Expected Results and Benefits

This research project is expected to achieve substantial improvements in the performance of the Perceptron model. The results obtained will be documented in detail and shared with the community, providing valuable guidance for optimizing other artificial intelligence projects. Furthermore, this project will contribute to a better understanding of code optimization techniques and their application in the development of machine learning algorithms.

As he explains, the example code simply uses 'xor r0q, r0q' to generate 0. This is reminiscent of shellcode programming in an ASCII space where returning 0 is not an option. I am also aware of another option that I will test for speed to determine if it functions similarly to 'r0q'. If that is not possible, then 't0q' (xor t0q, t0q) could be an alternative. I need test it. Other example is m4q,m5q.. But now I not test it. In addition, it is already possible to do a significant percentage of the Perceptron code, since it allows for double loops in a fairly high intensity optimisation. We will then proceed to analyse the most interesting parts of the article, after which we will implement the first versions in ASM and optimise them. 

 

So according to what he tells us. With that code example simply with "xor r0q,r0q" as a method of generating 0. This reminds me of shellcode..

 

Other implementation of SSE

He talk about percents of computer compability instructions around the world...

Testing first MMX and float optimization

Now.... I code fast.... I need sleep. Commit code and today solve errerors and others... :P. Im my test start with float and MMX optimizations... Next SSE ;)

AI & Chatbots

Name Category Language Description
OpenCV Computer Vision C++ Computer vision library that includes tools for machine learning.
TensorFlow C++ API Deep Learning C++ TensorFlow API for C++ that allows implementing deep learning models.
Dlib Machine Learning C++ C++ library containing tools for machine learning and computer vision.
Caffe Deep Learning C++ Deep learning framework developed by Berkeley University.
MLpack Machine Learning C++ Fast and flexible C++ machine learning library.
Shogun Machine Learning C++ Machine learning library supporting multiple languages, including C++.
CNTK Deep Learning C++ Deep learning framework developed by Microsoft.
FANN Neural Networks C Fast artificial neural network library in C.
NVIDIA cuDNN Deep Learning C++ Deep learning primitives library for NVIDIA GPUs.
Torch Deep Learning C++ Deep learning framework with a C++ implementation.
ONNX Runtime Model Inference C++ Inference engine for ONNX models with C++ support.
LibSVM Support Vector Machines C++ Support vector machine library in C++.
LibLinear Linear Classification C++ Library for large-scale linear classification in C++.
Bayes++ Bayesian Networks C++ C++ library for Bayesian networks.
GRT Gesture Recognition C++ C++ library for gesture recognition.

Language Generation & Understand

Name Category Language Description
ANTLR Parser Generation C++ Tool for generating lexical and syntactic parsers in C++.
LLVM Compilers C++ Toolset and libraries for building compilers and programming languages.
Clang Compilers C++ C/C++ compiler based on LLVM providing tools for code analysis and transformation.
Flex Lexer Generation C Tool for generating lexical analyzers in C.
Bison Parser Generation C Tool for generating syntactic parsers in C.
ROSE Compiler Framework Code Analysis C++ Framework for analyzing and transforming C/C++ source code.

Translation

Name Category Lang Description
Google Translator API Machine Translation C++ C++ library for communicating with the Google Translate API.
Apertium Machine Translation C++ Open-source machine translation platform including tools in C++.
Moses Machine Translation C++ Statistical machine translation system with components in C++.
Marian NMT Machine Translation C++ Neural machine translation framework in C++.
Tesseract OCR C++ Optical character recognition engine in C++ useful for translating scanned text.

IA & ChatBots

Name Lang Wappers API Publish Categort Description
ChatterBot Python Python No 2014 Python library for creating chatbots that can learn from conversations.
RiveScript Go, Java, JavaScript, Perl, Python RiveScript No 2000 Simple scripting language for creating chatbots and automated response systems.
AIMLBot Java AIML No 2002 AIML implementation for creating chatbots.
PyAIML Python AIML No 2003 AIML implementation in Python for creating chatbots.
NLTK Python Python No 2001 Python toolkit for natural language processing.
spaCy Python Python No 2015 Python library for advanced natural language processing.
Botkit JavaScript JavaScript No 2015 Development tool for creating chatbots and conversational applications.
DeepPavlov Python Python No 2018 Python framework for building dialogue systems and chatbots.
TextBlob Python Python No 2013 Python library for easy-to-use natural language processing.
OpenNLP Java Java No 2010 Java library for natural language processing.
BotUI JavaScript JavaScript No 2016 JavaScript framework for creating chatbot user interfaces.
PyDial Python Python No 2017 Python platform for developing dialogue systems.
Rasa NLU Python Python No 2016 Python framework for building chatbots and virtual assistants.
Tock Java, Kotlin Java, Kotlin No 2017 Open-source platform for building chatbots and conversational assistants.
BotMan PHP PHP No 2016 PHP framework for creating chatbots.

SCENE / PANORMA....

OTHERS

Name Lang Wrapper API Year Category Description
Botpress JavaScript JavaScript No 2016 Open-source platform for creating custom chatbots.
Pandorabots AIML AIML No 2000 Cloud-based platform for creating chatbots using AIML.
Rasa Python Python No 2016 Python framework for building conversational assistants.
ChatScript C++ ChatScript No 2011 Natural language engine and dialogue management system.
Golem Go, Python, JavaScript, Lua Go, Python, JavaScript, Lua No 2020 General scripting language for building distributed systems.
Microsoft Bot Framework C#, JavaScript, Python C#, JavaScript, Python No 2016 Microsoft framework for building conversational AI experiences.
IBM Watson Assistant Java, Python Java, Python No 2011 IBM platform for creating intelligent virtual assistants.
Dialogflow JavaScript, Python JavaScript, Python No 2016 Google platform for creating conversational interfaces.
TARS C++, Java, Node.js, PHP, Python C++, Java, Node.js, PHP, Python No 2017 Microservices framework for developing and deploying applications.
Wit.ai JavaScript JavaScript No 2013 NLP platform for creating chatbots and voice assistants.
SnatchBot JavaScript JavaScript No 2015 Chatbot platform for creating and managing chatbots.
Flow XO JavaScript JavaScript No 2015 Automation platform for creating chatbots and workflows.
ManyChat JavaScript JavaScript No 2015 Marketing platform for creating social media chatbots.
Landbot JavaScript JavaScript No 2017 Chatbot platform for creating conversational experiences.
Tidio JavaScript JavaScript No 2014 Chatbot platform for improving customer support.

OTROS

Nombre Lenguaje Wrapper API Año Categoria Descripción
Botpress JavaScript JavaScript No 2016 Plataforma de código abierto para crear chatbots personalizados.
Pandorabots AIML AIML No 2000 Plataforma basada en la nube para crear chatbots usando AIML.
Rasa Python Python No 2016 Framework de Python para construir asistentes conversacionales.
ChatScript C++ ChatScript No 2011 Motor de lenguaje natural y sistema de gestión de diálogos.
Golem Go, Python, JavaScript, Lua Go, Python, JavaScript, Lua No 2020 Lenguaje de scripting general para construir sistemas distribuidos.
Microsoft Bot Framework C#, JavaScript, Python C#, JavaScript, Python No 2016 Framework de Microsoft para construir experiencias de IA conversacional.
IBM Watson Assistant Java, Python Java, Python No 2011 Plataforma de IBM para crear asistentes virtuales inteligentes.
Dialogflow JavaScript, Python JavaScript, Python No 2016 Plataforma de Google para crear interfaces conversacionales.
TARS C++, Java, Node.js, PHP, Python C++, Java, Node.js, PHP, Python No 2017 Framework de microservicios para desarrollar y desplegar aplicaciones.
Wit.ai JavaScript JavaScript No 2013 Plataforma de NLP para crear chatbots y asistentes de voz.
SnatchBot JavaScript JavaScript No 2015 Plataforma de chatbot para crear y gestionar chatbots.
Flow XO JavaScript JavaScript No 2015 Plataforma de automatización para crear chatbots y flujos de trabajo.
ManyChat JavaScript JavaScript No 2015 Plataforma de marketing para crear chatbots en redes sociales.
Landbot JavaScript JavaScript No 2017 Plataforma de chatbot para crear experiencias conversacionales.
Tidio JavaScript JavaScript No 2014 Plataforma de chatbot para mejorar la atención al cliente.
Tidio JavaScript JavaScript No 2014 Plataforma de chatbot para mejorar la atención al cliente.