This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DIscussion, Cortex-a53 support pthread with 4 cores work together

I am ruining Pthread application on cortex-a53 which has 4 cores. And I also run the same application on the server with 8 arm cores to make a comparison.

A problem is there is bare performance improvement on cotex-a53 with 4 cores. However the improvement on 8-arm cores server is obvious when increase the thread from 1-8. See below:

 

fig.1

 

I am suspect that the cotex-a53 only working with one core (not four) with the pthread application. So I checked the status of the 4 cores using XSCT in SDK when I running my application. The result shows only one core is in running status see that below:

fig. 2

I am not sure whether it is believable to check the status of the cores using XSCT. But according to the result from XSCT and result on fig.1 it seems only on core of the 4 cortex-53 is running. 

 

Does anyone could help me confirm whither I am  correct or not?

If my suspect is corrt, how could I run the application on 4 cores at the same time?

 

Thanks in advance.

Parents
  • Hi @42Bastian Schick 

    Yes it is linux system running in the embedded ARM cortex-a53 in a XIlinx Zynq FPGA.

    Yes the SMP is enable:

     

    I also tried to use pthread_setaffinity_np to  bind the thread to different cores (The code could be found at the bottom of the text).

    pthread_setaffinity_np: http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html

    he code's function (source: at the end of the text ) is create a thread and execution the thread on each core:

    The result from arm server (which has 8cores):

    The result from the Cortex-a53 (has 4 cores) in the Zynq UltralScale+ MpSOC:

    The system can detect 4 cores but cannt run the thread on the other three cores.

    Is there  a setting I need to enable the other three cores linux system ?

     

    The code I used.

    #define _GNU_SOURCE
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <pthread.h>
    #include <sched.h>
    void *myfun(void *arg)
    {
        cpu_set_t mask;
        cpu_set_t get;
        char buf[256];
        int i;
        int j;
        int num = sysconf(_SC_NPROCESSORS_CONF);
        printf("system has %d processor(s)\n", num);
        for (i = 0; i < num; i++) {
            CPU_ZERO(&mask);
            CPU_SET(i, &mask);
            if (pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) < 0) {
                fprintf(stderr, "set thread affinity failed\n");
            }
            CPU_ZERO(&get);
            if (pthread_getaffinity_np(pthread_self(), sizeof(get), &get) < 0) {
                fprintf(stderr, "get thread affinity failed\n");
            }
            for (j = 0; j < num; j++) {
                if (CPU_ISSET(j, &get)) {
                    printf("thread %d is running in processor %d\n", (int)pthread_self(), j);
                }
            }
            j = 0;
            while (j++ < 100000000) {
                memset(buf, 0, sizeof(buf));
            }
        }
        pthread_exit(NULL);
    }
    int main(int argc, char *argv[])
    {
        pthread_t tid;
        if (pthread_create(&tid, NULL, (void *)myfun, NULL) != 0) {
            fprintf(stderr, "thread create failed\n");
            return -1;
        }
        pthread_join(tid, NULL);
        return 0;
    }
Reply
  • Hi @42Bastian Schick 

    Yes it is linux system running in the embedded ARM cortex-a53 in a XIlinx Zynq FPGA.

    Yes the SMP is enable:

     

    I also tried to use pthread_setaffinity_np to  bind the thread to different cores (The code could be found at the bottom of the text).

    pthread_setaffinity_np: http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html

    he code's function (source: at the end of the text ) is create a thread and execution the thread on each core:

    The result from arm server (which has 8cores):

    The result from the Cortex-a53 (has 4 cores) in the Zynq UltralScale+ MpSOC:

    The system can detect 4 cores but cannt run the thread on the other three cores.

    Is there  a setting I need to enable the other three cores linux system ?

     

    The code I used.

    #define _GNU_SOURCE
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <unistd.h>
    #include <pthread.h>
    #include <sched.h>
    void *myfun(void *arg)
    {
        cpu_set_t mask;
        cpu_set_t get;
        char buf[256];
        int i;
        int j;
        int num = sysconf(_SC_NPROCESSORS_CONF);
        printf("system has %d processor(s)\n", num);
        for (i = 0; i < num; i++) {
            CPU_ZERO(&mask);
            CPU_SET(i, &mask);
            if (pthread_setaffinity_np(pthread_self(), sizeof(mask), &mask) < 0) {
                fprintf(stderr, "set thread affinity failed\n");
            }
            CPU_ZERO(&get);
            if (pthread_getaffinity_np(pthread_self(), sizeof(get), &get) < 0) {
                fprintf(stderr, "get thread affinity failed\n");
            }
            for (j = 0; j < num; j++) {
                if (CPU_ISSET(j, &get)) {
                    printf("thread %d is running in processor %d\n", (int)pthread_self(), j);
                }
            }
            j = 0;
            while (j++ < 100000000) {
                memset(buf, 0, sizeof(buf));
            }
        }
        pthread_exit(NULL);
    }
    int main(int argc, char *argv[])
    {
        pthread_t tid;
        if (pthread_create(&tid, NULL, (void *)myfun, NULL) != 0) {
            fprintf(stderr, "thread create failed\n");
            return -1;
        }
        pthread_join(tid, NULL);
        return 0;
    }
Children