Search This Blog

Friday, October 18, 2024

Open ai - azure services

 Great video series 

https://anythingllm.com/

Open ai links 


Use AI to chat with a SQL Database 2.0

https://www.youtube.com/watch?v=hw6oTjw9_Ro https://www.youtube.com/watch?v=REw3y_Jv3Ig





Learn Azure OpenAI - Getting Started

https://www.youtube.com/watch?v=c66y0W5KFVY



Stable Diffusion AI - a simple intro. Set up and create AI images locally

https://www.youtube.com/watch?v=_K2E0kJfb8A



Local AI models! Code with Ollama and Phi3.

https://www.youtube.com/watch?v=177qX6mpyMg


Use Semantic Kernel to build AI Apps and Agents - a simple intro!

Add power (extension) to openai - e.g. get from rss live content

https://www.youtube.com/watch?v=kCGZPhnTGHM


Host your own AI Model in 10 minutes...for free!

Docker - for ollama - all in azure

https://www.youtube.com/watch?v=WKj8lo-ZbY4





https://www.youtube.com/watch?v=fFgyOucIFuk

https://www.youtube.com/watch?v=ztBJqzBU5kc


private GPT
https://github.com/zylon-ai/private-gpt

https://www.youtube.com/watch?v=XFiof0V3nhA




Great sample 


azure real time api

https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/voicerag-an-app-pattern-for-rag-voice-using-azure-ai-search-and/ba-p/4259116


https://www.youtube.com/watch?v=u5Vcrwpzoz8

https://www.youtube.com/watch?v=i-txsBoTJtI



Tuesday, April 2, 2024

Cpu cycles counter for linux in C++

 #include <stdio.h>

#include <stdlib.h>
#include <unistd.h>
#include <asm/unistd.h>
#include <linux/perf_event.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdint.h>
// Structure for perf_event_attr
struct perf_event_attr pe;


// need permsiion  on perf_event_open
// to see value ->
// cat /proc/sys/kernel/perf_event_paranoid

//0: Allows access to all users to use perf_event_open for monitoring performance events.
//1: Allows access only to privileged users (typically root) to use perf_event_open.
//2: Disallows access to all users to use perf_event_open

//sudo sysctl kernel.perf_event_paranoid=<new_value>

// Function to initialize and read CPU cycle count
uint64_t read_cpu_cycles() {
    // Initialize perf_event_attr structure
    memset(&pe, 0, sizeof(struct perf_event_attr));
    pe.type = PERF_TYPE_HARDWARE;
    pe.config = PERF_COUNT_HW_CPU_CYCLES;

    // Open the event
    int fd = syscall(__NR_perf_event_open, &pe, 0, -1, -1, 0);
    if (fd == -1) {
        perror("Error opening leader %llx");
        //exit(EXIT_FAILURE);
        return 0;
    }

    // Read the counter
    uint64_t count;
    read(fd, &count, sizeof(uint64_t));

    // Close the event
    close(fd);

    return count;
}

Tuesday, January 9, 2024

Handling Large file - generated

Dealing with Large Symbol Files


nice tool to compress exe or runtime file on linux 
use UPX

Tuesday, December 26, 2023

C++ improve your memory allocation

 

Arena allocation is a C++-only feature that helps you optimize your memory usage and improve performance when working with protocol buffers.


C++ Arena Allocation Guide




Saturday, June 3, 2023

Thursday, March 30, 2023

Monday, March 27, 2023

Debugging C++ , with VSCode & GDB command ( improve loading performance tip for heavy projects)

 Its all about symbols that loaded into memory in the debug process.

 With VScode could takes time just to get into your breakpoint, on huge c++ project , with many so files and dependencies. 
sometimes moving with F10 takes time , and looks like vscode screen is freezing.
to fix this issue and get much better vscode debug performance follow the next steps:
add to launch.json file as follow the next section, make sure in the exceptionList you have your brand so file .
the section below prevent loading extra symbols that you don't need to debug.
you can add many so file is the exceptionList separated by semicolon "tttt.so;yyy.so"

"symbolLoadInfo": {
                "loadAll": false,
                "exceptionList": "libMyShared.so"
            },  

The next tip with VScode - make sure to close the Local list in the VARIABLES group

GDB 

to work with gdb command line make sure all the symbolic will not loaded , the default is ON.

the next parameter control such behavior

in gdb type 'set auto-solib-add off' - disabled loading any symbolic files.


you can start your program 

and when your SO files loaded , you can CTRL-C 

and use the share command to load your so symbolic file.

share /path/mysofile.so 


option 2 : put in your program the next line 

__asm__ volatile("int $0x03");


its will break into your gdb and use share command to load your symbolic .




enjoy 

Yaniv Tzanany

Monday, March 20, 2023

C++ custom debugger view for VisualCode

you can add custom view  for debugger.

https://www.cppstories.com/2021/natvis-tutorial/

https://devblogs.microsoft.com/cppblog/debug-visualizers-in-visual-c-2015/

create into your root folder  xxx.natvis

make sure in the launch.json  to add

            "visualizerFile": "${workspaceFolder}/xxx.natvis",
            "showDisplayString": true,

more sample:

 https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2019

note:

the Name of the class must be full qualified e.g. contain namespace name if exist.

even typedef name should be act as new Name in the natvis file.

ty  

enjoy

Yaniv 

sample template class:

template<typename T> class MyObject
{
public:
    MyObject() : myVal( 5 ) {}
    T myVal;
};


sample template  natvis file:

<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">

<Type Name="MyObject&lt;*&gt;">
  <DisplayString>{{myVal = {myVal}}}</DisplayString>
  <Expand>
    <Item Name="[myVal]">myVal</Item>
  </Expand>
</Type> 
</AutoVisualizer>

Sunday, March 12, 2023

C++ struct alignment - can save you memory

 the orders of members in a struct affect sizeof of struct 


see this example https://www.joshcaratelli.com/blog/struct-packing


if no compiler directive - memory align to 8 bytes by default

struct top

{

    char* p; //8 bytes

    int i;  //4 bytes

    short s; // 2 bytes

    char c;  // 1 byte

                    // 1 padding 

    int t; // 4 bytes

                    // 4 padding 

};

struct buttom

{

    char c; // 1 bytes -- 7 padding

    char* p; //8 bytes

    short s;  //2 bytes

    int i;   //4 bytes

               // 2 padding

    int t;  // 4 bytes 

               // 4 padding

        

};

    int sizeTop = sizeof(top);   // =>24

    int sizeButtom = sizeof(buttom); // =>32

Saturday, January 28, 2023

C++ performance - hardware

++

 very impressive guide 





read about 

Profile-guided optimization (PGO)  and WPO  -- its free compiler option that can boost your program.






Wednesday, January 25, 2023