test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH] crb.py: Support getting cores list from last core
@ 2019-05-30 10:47 pvukkisala
  2019-06-05  2:18 ` Tu, Lijuan
  0 siblings, 1 reply; 2+ messages in thread
From: pvukkisala @ 2019-05-30 10:47 UTC (permalink / raw)
  To: dts; +Cc: avijay, fmasood, Phanendra Vukkisala

From: Phanendra Vukkisala <pvukkisala@marvell.com>

Signed-off-by: Phanendra Vukkisala <pvukkisala@marvell.com>
---
 framework/crb.py |   37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/framework/crb.py b/framework/crb.py
index 0a2fa80..6e5f56f 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -630,7 +630,7 @@ class Crb(object):
         # return thread list
         return map(str, thread_list)
 
-    def get_core_list(self, config, socket=-1):
+    def get_core_list(self, config, socket=-1, from_last = False):
         """
         Get lcore array according to the core config like "all", "1S/1C/1T".
         We can specify the physical CPU socket by the "socket" parameter.
@@ -663,7 +663,10 @@ class Crb(object):
                     if (int(n['socket']) == socket):
                         sockList = [int(n['socket'])]
 
-            sockList = list(sockList)[:nr_sockets]
+            if from_last:
+                sockList = list(sockList)[-nr_sockets:]
+            else:
+                sockList = list(sockList)[:nr_sockets]
             partial_cores = [n for n in partial_cores if int(n['socket'])
                              in sockList]
             core_list = set([int(n['core']) for n in partial_cores])
@@ -676,7 +679,10 @@ class Crb(object):
             for sock in sockList:
                 core_list = set([int(
                     n['core']) for n in partial_cores if int(n['socket']) == sock])
-                core_list = list(core_list)[:nr_cores]
+                if from_last:
+                    core_list = list(core_list)[-nr_cores:]
+                else:
+                    core_list = list(core_list)[:nr_cores]
                 temp.extend(core_list)
 
             core_list = temp
@@ -686,7 +692,10 @@ class Crb(object):
                 partial_cores = self.cores
                 sockList = set([int(n['socket']) for n in partial_cores])
 
-                sockList = list(sockList)[:nr_sockets]
+                if from_last:
+                    sockList = list(sockList)[-nr_sockets:]
+                else:
+                    sockList = list(sockList)[:nr_sockets]
                 partial_cores = [n for n in partial_cores if int(
                     n['socket']) in sockList]
 
@@ -694,7 +703,10 @@ class Crb(object):
                 for sock in sockList:
                     core_list = list([int(n['thread']) for n in partial_cores if int(
                         n['socket']) == sock])
-                    core_list = core_list[:nr_cores]
+                    if from_last:
+                        core_list = core_list[-nr_cores:]
+                    else:
+                        core_list = core_list[:nr_cores]
                     temp.extend(core_list)
 
                 core_list = temp
@@ -716,23 +728,32 @@ class Crb(object):
                 for core in coreList_aux:
                     thread_list = list([int(n['thread']) for n in partial_cores if (
                         (int(n['core']) == core) and (int(n['socket']) == sock))])
-                    thread_list = thread_list[:nr_threads]
+                    if from_last:
+                        thread_list = thread_list[-nr_threads:]
+                    else:
+                        thread_list = thread_list[:nr_threads]
                     temp.extend(thread_list)
                     thread_list = temp
                 i += 1
             return map(str, thread_list)
 
-    def get_lcore_id(self, config):
+    def get_lcore_id(self, config, inverse = False):
         """
         Get lcore id of specified core by config "C{socket.core.thread}"
         """
 
-        m = re.match("C{([01]).(\d).([01])}", config)
+        m = re.match("C{([01]).(\d+).([01])}", config)
 
         if m:
             sockid = m.group(1)
             coreid = int(m.group(2))
+            if inverse:
+                coreid += 1
+                coreid = -coreid
             threadid = int(m.group(3))
+            if inverse:
+                threadid += 1
+                threadid = -threadid
 
             perSocklCs = [_ for _ in self.cores if _['socket'] == sockid]
             coreNum = perSocklCs[coreid]['core']
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dts] [PATCH] crb.py: Support getting cores list from last core
  2019-05-30 10:47 [dts] [PATCH] crb.py: Support getting cores list from last core pvukkisala
@ 2019-06-05  2:18 ` Tu, Lijuan
  0 siblings, 0 replies; 2+ messages in thread
From: Tu, Lijuan @ 2019-06-05  2:18 UTC (permalink / raw)
  To: pvukkisala, dts; +Cc: avijay, fmasood

Applied, thanks

> -----Original Message-----
> From: dts [mailto:dts-bounces@dpdk.org] On Behalf Of
> pvukkisala@marvell.com
> Sent: Thursday, May 30, 2019 6:47 PM
> To: dts@dpdk.org
> Cc: avijay@marvell.com; fmasood@marvell.com; Phanendra Vukkisala
> <pvukkisala@marvell.com>
> Subject: [dts] [PATCH] crb.py: Support getting cores list from last core
> 
> From: Phanendra Vukkisala <pvukkisala@marvell.com>
> 
> Signed-off-by: Phanendra Vukkisala <pvukkisala@marvell.com>
> ---
>  framework/crb.py |   37 +++++++++++++++++++++++++++++--------
>  1 file changed, 29 insertions(+), 8 deletions(-)
> 
> diff --git a/framework/crb.py b/framework/crb.py index 0a2fa80..6e5f56f
> 100644
> --- a/framework/crb.py
> +++ b/framework/crb.py
> @@ -630,7 +630,7 @@ class Crb(object):
>          # return thread list
>          return map(str, thread_list)
> 
> -    def get_core_list(self, config, socket=-1):
> +    def get_core_list(self, config, socket=-1, from_last = False):
>          """
>          Get lcore array according to the core config like "all", "1S/1C/1T".
>          We can specify the physical CPU socket by the "socket" parameter.
> @@ -663,7 +663,10 @@ class Crb(object):
>                      if (int(n['socket']) == socket):
>                          sockList = [int(n['socket'])]
> 
> -            sockList = list(sockList)[:nr_sockets]
> +            if from_last:
> +                sockList = list(sockList)[-nr_sockets:]
> +            else:
> +                sockList = list(sockList)[:nr_sockets]
>              partial_cores = [n for n in partial_cores if int(n['socket'])
>                               in sockList]
>              core_list = set([int(n['core']) for n in partial_cores]) @@ -676,7
> +679,10 @@ class Crb(object):
>              for sock in sockList:
>                  core_list = set([int(
>                      n['core']) for n in partial_cores if int(n['socket']) == sock])
> -                core_list = list(core_list)[:nr_cores]
> +                if from_last:
> +                    core_list = list(core_list)[-nr_cores:]
> +                else:
> +                    core_list = list(core_list)[:nr_cores]
>                  temp.extend(core_list)
> 
>              core_list = temp
> @@ -686,7 +692,10 @@ class Crb(object):
>                  partial_cores = self.cores
>                  sockList = set([int(n['socket']) for n in partial_cores])
> 
> -                sockList = list(sockList)[:nr_sockets]
> +                if from_last:
> +                    sockList = list(sockList)[-nr_sockets:]
> +                else:
> +                    sockList = list(sockList)[:nr_sockets]
>                  partial_cores = [n for n in partial_cores if int(
>                      n['socket']) in sockList]
> 
> @@ -694,7 +703,10 @@ class Crb(object):
>                  for sock in sockList:
>                      core_list = list([int(n['thread']) for n in partial_cores if int(
>                          n['socket']) == sock])
> -                    core_list = core_list[:nr_cores]
> +                    if from_last:
> +                        core_list = core_list[-nr_cores:]
> +                    else:
> +                        core_list = core_list[:nr_cores]
>                      temp.extend(core_list)
> 
>                  core_list = temp
> @@ -716,23 +728,32 @@ class Crb(object):
>                  for core in coreList_aux:
>                      thread_list = list([int(n['thread']) for n in partial_cores if (
>                          (int(n['core']) == core) and (int(n['socket']) == sock))])
> -                    thread_list = thread_list[:nr_threads]
> +                    if from_last:
> +                        thread_list = thread_list[-nr_threads:]
> +                    else:
> +                        thread_list = thread_list[:nr_threads]
>                      temp.extend(thread_list)
>                      thread_list = temp
>                  i += 1
>              return map(str, thread_list)
> 
> -    def get_lcore_id(self, config):
> +    def get_lcore_id(self, config, inverse = False):
>          """
>          Get lcore id of specified core by config "C{socket.core.thread}"
>          """
> 
> -        m = re.match("C{([01]).(\d).([01])}", config)
> +        m = re.match("C{([01]).(\d+).([01])}", config)
> 
>          if m:
>              sockid = m.group(1)
>              coreid = int(m.group(2))
> +            if inverse:
> +                coreid += 1
> +                coreid = -coreid
>              threadid = int(m.group(3))
> +            if inverse:
> +                threadid += 1
> +                threadid = -threadid
> 
>              perSocklCs = [_ for _ in self.cores if _['socket'] == sockid]
>              coreNum = perSocklCs[coreid]['core']
> --
> 1.7.9.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-05  2:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 10:47 [dts] [PATCH] crb.py: Support getting cores list from last core pvukkisala
2019-06-05  2:18 ` Tu, Lijuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).