UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Explorer
Explorer
2,204 Views
Registered: ‎05-23-2017

how to run applicaiton using all cores of cortex-a53

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:

 

2.JPG

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:

1.JPG

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.

 

 

 

 

0 Kudos
2 Replies
Teacher muzaffer
Teacher
2,173 Views
Registered: ‎03-31-2012

Re: how to run applicaiton using all cores of cortex-a53

@mathmaxsean it seems like you are running in the stand-alone mode. If yes, that mode doesn't support multi-threading. You need a multi-threaded OS (ala linux) to do that.

- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
0 Kudos
Explorer
Explorer
2,148 Views
Registered: ‎05-23-2017

Re: how to run applicaiton using all cores of cortex-a53

I am using linux application mode and it is not stand alone mode.

I build the applicaiton and run it on the linux.

 

Now just only one core working no matter how much threads I use.

 

I tried to bind the thread to different cores with the function of  pthread_setaffinity_np :http://man7.org/linux/man-pages/man3/pthread_setaffinity_np.3.html

But still cannot invoke the other three cores of cortex-a53. But the same code could work on an arm server.:

 

 

I tried this functions.as below  (the 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):

7.JPG

 

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

8.JPG

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

9.JPG

I wonder do we need to enable some function of the linux system or petalinux/SDk.

I also check my arm-linux system, The SMP is enable.

What else?

 

 

 

 

 

 

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;
}

 

 

0 Kudos