def hook_schedLockClient(self, event, payload):
        taskId = event["id"]
        timeAcq = event["ts_acquire"]
        cpuId = ExecutionModel.getCurrentCPUId()
        stack = self.getEventStack(event)

        # Emit event in the past. We know that no tracepoint can be emitted
        # between getting the lock and after the operation completes
        # (at this point as a client). Hence, it is safe the override the
        # standard path and enforce another tracepoint here.
        pastPayload = [(ExtraeEventTypes.RUNTIME_SUBSYSTEMS,
                        self.Status.SchedulerLockEnter)]
        ParaverTrace.emitEvent(timeAcq, cpuId, pastPayload)

        # Emit communication line (if present) before any current event as
        # requried by paraver. This line shows a relation between a worker
        # serving task and another worker being assigned work by it.
        if taskId != 0:
            timeRel = ExecutionModel.getCurrentTimestamp()
            (timeSend, cpuSendId) = self._servedTasks[taskId]
            ParaverTrace.emitCommunicationEvent(cpuSendId, timeSend, cpuId,
                                                timeRel)

        # Emit event at this point in time using the standard path
        payload.append((ExtraeEventTypes.RUNTIME_SUBSYSTEMS, stack[-1]))
    def __init__(self):
        super().__init__()
        self._hooks = [
            ("sched_switch", self.hook_schedSwitch),
            ("irq_handler_entry", self.hook_irq),
            ("irq_handler_exit", self.hook_irqExit),
            ("softirq_entry", self.hook_softIrq),
            ("softirq_exit", self.hook_softIrqExit),
        ]

        # We only need to set up manually the idle thread and the traced
        # application Paraver entries, the other processes entries will be
        # installed in the callback_newProcessName
        binaryName = ParaverTrace.getBinaryName()
        values = {
            self.Status.Idle:
            "Idle",  # The KernelModel always sets up id 0 for Idle threads
            self.Status.ThisProcess:
            binaryName,  # The KernelModel always sets up id 1 for the traced app
            self.Status.Irq: "IRQ",
            self.Status.SoftIrq: "Soft IRQ",
        }
        ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.KERNEL_PREEMPTIONS,
                                          values, "Kernel Preemptions")
        KernelModel.registerNewProcessNameCallback(
            self.callback_newProcessName)
        KernelModel.registerNewThreadCallback(self.callback_newThread)
    def __init__(self):
        super().__init__()
        self._hooks = [
            ("nanos6:thread_suspend", self.hook_getHardwareCounters),
            ("nanos6:thread_shutdown", self.hook_getHardwareCounters),
            ("nanos6:task_start", self.hook_getHardwareCounters),
            ("nanos6:task_end", self.hook_getHardwareCounters),
            ("nanos6:tc:task_create_enter", self.hook_getHardwareCounters),
            ("nanos6:tc:task_submit_exit", self.hook_getHardwareCounters),
            ("nanos6:tc:taskwait_enter", self.hook_getHardwareCounters),
            ("nanos6:tc:taskwait_exit", self.hook_getHardwareCounters),
            ("nanos6:tc:waitfor_enter", self.hook_getHardwareCounters),
            ("nanos6:tc:waitfor_exit", self.hook_getHardwareCounters),
            ("nanos6:tc:mutex_lock_enter", self.hook_getHardwareCounters),
            ("nanos6:tc:mutex_lock_exit", self.hook_getHardwareCounters),
            ("nanos6:tc:mutex_unlock_enter", self.hook_getHardwareCounters),
            ("nanos6:tc:mutex_unlock_exit", self.hook_getHardwareCounters),
            ("nanos6:tc:blocking_api_block_enter",
             self.hook_getHardwareCounters),
            ("nanos6:tc:blocking_api_block_exit",
             self.hook_getHardwareCounters),
            ("nanos6:tc:blocking_api_unblock_enter",
             self.hook_getHardwareCounters),
            ("nanos6:tc:blocking_api_unblock_exit",
             self.hook_getHardwareCounters),
            ("nanos6:tc:spawn_function_enter", self.hook_getHardwareCounters),
            ("nanos6:tc:spawn_function_exit", self.hook_getHardwareCounters),
        ]

        self._eventsHardwareCounters = ExtraeEventCollection(3900000, 7)
        self._eventsHardwareCounters.addEvents(hardwareCountersDefinitions)
        ParaverTrace.addEventCollection(self._eventsHardwareCounters)
    def __init__(self):
        super().__init__()
        self._hooks = [
            ("sched_switch", self.hook_schedSwitch),
        ]
        self._syscallMap = {}
        self._sys_enter_prefix = len("sys_enter_")
        self._sys_exit_prefix = len("sys_exit_")

        binaryName = ParaverTrace.getBinaryName()

        values = {
            0: "Idle",
            1: binaryName,
            2: "Other Process",
        }

        # Create hooks based on the available syscalls detected
        syscallsEntry, syscallsExit = KernelModel.getSyscallDefinitions()

        index = 3
        for syscall in syscallsEntry:
            self._hooks.append((syscall, self.hook_syscallEntry))
            # Create and map id for this syscall in Paraver's pcf
            name = syscall[self._sys_enter_prefix:]
            self._syscallMap[name] = index
            values[index] = name
            index += 1

        for syscall in syscallsExit:
            self._hooks.append((syscall, self.hook_syscallExit))

        ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.KERNEL_SYSCALLS,
                                          values, "Kernel System Calls")
        KernelModel.registerNewThreadCallback(self.callback_newThread)
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:task_start", self.hook_taskExecute),
         ("nanos6:task_end", self.hook_taskStop),
         ("nanos6:tc:task_create_enter", self.hook_taskStop),
         ("nanos6:tc:task_submit_exit", self.hook_taskExecute),
         ("nanos6:tc:taskwait_enter", self.hook_taskStop),
         ("nanos6:tc:taskwait_exit", self.hook_taskExecute),
         ("nanos6:tc:waitfor_enter", self.hook_taskStop),
         ("nanos6:tc:waitfor_exit", self.hook_taskExecute),
         ("nanos6:tc:mutex_lock_enter", self.hook_taskStop),
         ("nanos6:tc:mutex_lock_exit", self.hook_taskExecute),
         ("nanos6:tc:mutex_unlock_enter", self.hook_taskStop),
         ("nanos6:tc:mutex_unlock_exit", self.hook_taskExecute),
         ("nanos6:tc:blocking_api_block_enter", self.hook_taskStop),
         ("nanos6:tc:blocking_api_block_exit", self.hook_taskExecute),
         ("nanos6:tc:blocking_api_unblock_enter", self.hook_taskStop),
         ("nanos6:tc:blocking_api_unblock_exit", self.hook_taskExecute),
         ("nanos6:tc:spawn_function_enter", self.hook_taskStop),
         ("nanos6:tc:spawn_function_exit", self.hook_taskExecute),
     ]
     values = {
         RuntimeActivity.End: "End",
         RuntimeActivity.Task: "Task",
     }
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNTIME_TASKS,
                                       values, "Runtime: Task Code")
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("sched_switch", self.hook_schedSwitch),
     ]
     ParaverTrace.addEventType(ExtraeEventTypes.KERNEL_THREAD_ID,
                               "Kernel Thread ID (TID)")
    def getVirtualCPU(cls, event):
        # bounded threads (worker threads) cpu_id event value always points to
        # the physical cpu id. All External Threads have the same cpu_id (all
        # of them share a stream). To distinguish them, we need to check their
        # tid event value. With its tid, we keep track of which "virtual cpu"
        # each of them belong. The Leader Thread has its own stream, and hence
        # it's cpu_id is already a valid virtual cpu_id (=maxCPUId+1)

        vcpuid = ExecutionModel.getCurrentCPUId()
        wtype = cls.getWorkerType(vcpuid)
        if wtype == WorkerType.WorkerThread:
            cp = cls._cpus[vcpuid]
        elif wtype == WorkerType.LeaderThread:
            cp = cls._cpus[vcpuid]
        else:  # WorkerType.ExternalThread
            tid = event["unbounded"]["tid"]
            thread = cls.getThread(tid)
            cp = thread.vcpu
            if cp == None:
                cp = VCPU()
                cp.externalThread = thread
                thread.vcpu = cp
                cls._cpus.append(cp)
                ParaverTrace.increaseVirtualCPUCount()
        return cp
Example #8
0
 def hook_threadCreate(self, event, payload):
     tid = event["tid"]
     assert (not tid in self._colorMap.keys())
     color = self._colorMap_indx
     self._colorMap[tid] = color
     self._colorMap_indx += 1
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNNING_THREAD_TID,
                                       {color: "thread " + str(tid)})
Example #9
0
    def hook_debugRegister(self, event, payload):
        name = event["name"]
        debugId = event["id"]

        extraeId = self.Status.Debug + debugId
        extraeName = "Debug: " + str(name)
        ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNTIME_SUBSYSTEMS,
                                          {extraeId: extraeName})
Example #10
0
 def _process_event(self, ts, event):
     hookList = self.__hooks[event.name]
     for hook in hookList:
         hook(event, self.__payload)
     if self.__payload:
         cpuId = RuntimeModel.getVirtualCPUId(event)
         ParaverTrace.emitEvent(ts, cpuId, self.__payload)
     self.__payload.clear()
Example #11
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:task_create_enter", self.hook_taskCreate),
     ]
     ParaverTrace.addEventType(ExtraeEventTypes.NUMBER_OF_CREATED_TASKS,
                               "Number of Created Tasks")
     self.createdTasksCount = 0
Example #12
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:thread_create", self.hook_threadCreate),
         ("nanos6:thread_shutdown", self.hook_threadShutdown),
     ]
     ParaverTrace.addEventType(ExtraeEventTypes.NUMBER_OF_CREATED_THREADS,
                               "Number of Created Threads")
     self.createdThreadsCount = 0
Example #13
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:thread_resume", self.hook_threadResume),
         ("nanos6:thread_suspend", self.hook_threadSuspend),
     ]
     ParaverTrace.addEventType(ExtraeEventTypes.NUMBER_OF_BLOCKED_THREADS,
                               "Number of Blocked Threads")
     self.blockedThreads = set()
Example #14
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:task_block", self.hook_taskBlock),
         ("nanos6:task_unblock", self.hook_taskUnblock),
     ]
     ParaverTrace.addEventType(ExtraeEventTypes.NUMBER_OF_BLOCKED_TASKS,
                               "Number of Blocked Tasks")
     self.blockedTasksCount = 0
Example #15
0
 def __init__(self):
     super().__init__()
     self._hooks = [("nanos6:task_execute", self.hook_taskExecute),
                    ("nanos6:task_block", self.hook_taskStop),
                    ("nanos6:task_end", self.hook_taskStop)]
     values = {
         RuntimeActivity.End: "End",
     }
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNNING_TASK_ID,
                                       values, "Task ID")
Example #16
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:task_execute", self.hook_taskExecute),
         ("nanos6:task_block", self.hook_taskStop),
         ("nanos6:task_end", self.hook_taskStop),
     ]
     ParaverTrace.addEventType(ExtraeEventTypes.NUMBER_OF_RUNNING_TASKS,
                               "Number of Running Tasks")
     self.runningTasksCount = 0
Example #17
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:thread_resume", self.hook_threadResume),
         ("nanos6:thread_suspend", self.hook_threadStop),
         ("nanos6:thread_shutdown", self.hook_threadStop),
     ]
     ParaverTrace.addEventType(ExtraeEventTypes.NUMBER_OF_RUNNING_THREADS,
                               "Number of Running Threads")
     self.runningThreadsCount = 0
Example #18
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:ctf_flush", self.hook_flush),
     ]
     values = {
         0: "End",
         1: "flush",
     }
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.CTF_FLUSH, values,
                                       "Nanos6 CTF buffers writes to disk")
     self.blockedThreads = set()
Example #19
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:thread_shutdown", self.hook_threadShutdown),
         ("nanos6:worker_enter_busy_wait", self.hook_enterBusyWait),
         ("nanos6:worker_exit_busy_wait", self.hook_exitBusyWait)
     ]
     values = {
         RuntimeActivity.End: "End",
         RuntimeActivity.BusyWaiting: "BusyWait",
     }
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNTIME_BUSYWAITING,
                                       values, "Runtime: Busy Waiting")
Example #20
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:thread_create", self.hook_initStack),
         ("nanos6:external_thread_create", self.hook_initStack),
         ("nanos6:thread_resume", self.hook_eventContinue),
         ("nanos6:external_thread_resume", self.hook_eventContinue),
         ("nanos6:thread_suspend", self.hook_eventStop),
         ("nanos6:external_thread_suspend", self.hook_eventStop),
         ("nanos6:thread_shutdown", self.hook_eventStop),
         ("nanos6:external_thread_shutdown", self.hook_eventStop),
         ("nanos6:task_execute", self.hook_task),
         ("nanos6:task_block", self.hook_unstack),
         ("nanos6:task_end", self.hook_unstack),
         ("nanos6:worker_enter_busy_wait", self.hook_busyWait),
         ("nanos6:worker_exit_busy_wait", self.hook_unstack),
         ("nanos6:dependency_register_enter", self.hook_dependencyRegister),
         ("nanos6:dependency_register_exit", self.hook_unstack),
         ("nanos6:dependency_unregister_enter",
          self.hook_dependencyUnregister),
         ("nanos6:dependency_unregister_exit", self.hook_unstack),
         ("nanos6:scheduler_add_task_enter", self.hook_schedulerAddTask),
         ("nanos6:scheduler_add_task_exit", self.hook_unstack),
         ("nanos6:scheduler_get_task_enter", self.hook_schedulerGetTask),
         ("nanos6:scheduler_get_task_exit", self.hook_unstack),
         ("nanos6:task_create_enter", self.hook_taskCreate),
         ("nanos6:task_create_exit", self.hook_taskBetweenCreateAndSubmit),
         ("nanos6:task_submit_enter", self.hook_taskSubmit),
         ("nanos6:task_submit_exit", self.hook_unstack),
         ("nanos6:taskfor_init_enter", self.hook_taskforInit),
         ("nanos6:taskfor_init_exit", self.hook_unstack),
         ("nanos6:debug_register", self.hook_debugRegister),
         ("nanos6:debug_enter", self.hook_debug),
         ("nanos6:debug_exit", self.hook_unstack),
     ]
     status = {
         self.Status.Idle: "Idle",
         self.Status.Runtime: "Runtime",
         self.Status.BusyWait: "Busy Wait",
         self.Status.Task: "Task",
         self.Status.DependencyRegister: "Dependency: Register",
         self.Status.DependencyUnregister: "Dependency: Unregister",
         self.Status.SchedulerAddTask: "Scheduler: Add Ready Task",
         self.Status.SchedulerGetTask: "Scheduler: Get Ready Task",
         self.Status.TaskCreate: "Task: Create",
         self.Status.TaskArgsInit: "Task: Arguments Init",
         self.Status.TaskSubmit: "Task: Submit",
         self.Status.TaskforInit: "Task: Taskfor Collaborator Init",
     }
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNTIME_SUBSYSTEMS,
                                       status, "Runtime Subsystems")
Example #21
0
    def __init__(self):
        super().__init__()
        self._hooks = [
            ("nanos6:thread_suspend", self.hook_getHardwareCounters),
            ("nanos6:thread_shutdown", self.hook_getHardwareCounters),
            ("nanos6:task_execute", self.hook_getHardwareCounters),
            ("nanos6:task_block", self.hook_getHardwareCounters),
            ("nanos6:task_end", self.hook_getHardwareCounters),
            ("nanos6:task_create_enter", self.hook_getHardwareCounters),
            ("nanos6:task_submit_exit", self.hook_getHardwareCounters),
        ]

        self._eventsHardwareCounters = ExtraeEventCollection(3900000, 7)
        self._eventsHardwareCounters.addEvents(hardwareCountersDefinitions)
        ParaverTrace.addEventCollection(self._eventsHardwareCounters)
Example #22
0
    def hook_flush(self, event, _):
        start = event["start"]
        end = event["end"]

        # In this view we are not emiting events trough the "payload" variable,
        # but we are emitting events directly. That's because we don't want to
        # use the current event timestamp as the extare timestamp but we want
        # to use the event's fields as timestamps. It is safe to do so becaue
        # on flushing, we know that no events could be emitted between the last
        # processed event and now, basically because nanos6 was flushing the
        # buffer :-)

        cpuId = RuntimeModel.getVirtualCPUId(event)
        ParaverTrace.emitEvent(start, cpuId, [(ExtraeEventTypes.CTF_FLUSH, 1)])
        ParaverTrace.emitEvent(end, cpuId, [(ExtraeEventTypes.CTF_FLUSH, 0)])
Example #23
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:task_label", self.hook_taskLabel),
         ("nanos6:task_start", self.hook_taskExecute),
         ("nanos6:task_end", self.hook_taskStop),
         ("nanos6:task_block", self.hook_taskStop),
         ("nanos6:task_unblock", self.hook_taskExecute),
         ("nanos6:thread_resume", self.hook_threadResume),
         ("nanos6:thread_suspend", self.hook_threadSuspend),
     ]
     values = {
         RuntimeActivity.End: "End",
     }
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNNING_TASK_SOURCE,
                                       values, "Running Task Source")
Example #24
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:thread_resume", self.hook_threadResume),
         ("nanos6:external_thread_resume", self.hook_threadResume),
         ("nanos6:thread_suspend", self.hook_threadStop),
         ("nanos6:external_thread_suspend", self.hook_threadStop),
         ("nanos6:thread_shutdown", self.hook_threadStop),
         ("nanos6:external_thread_shutdown", self.hook_threadStop),
     ]
     values = {
         RuntimeActivity.End: "End",
         RuntimeActivity.Runtime: "Runtime"
     }
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNTIME_CODE,
                                       values, "Runtime: Runtime Code")
Example #25
0
 def __init__(self):
     super().__init__()
     self._hooks = [
         ("nanos6:external_thread_create", self.hook_threadCreate),
         ("nanos6:thread_create", self.hook_threadCreate),
         ("nanos6:thread_resume", self.hook_threadResume),
         ("nanos6:external_thread_resume", self.hook_threadResume),
         ("nanos6:thread_suspend", self.hook_threadSuspend),
         ("nanos6:external_thread_suspend", self.hook_threadSuspend),
         ("nanos6:thread_shutdown", self.hook_threadSuspend),
         ("nanos6:external_thread_shutdown", self.hook_threadSuspend),
     ]
     self._colorMap = {}
     self._colorMap_indx = 1
     values = {
         RuntimeActivity.End: "End",
     }
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNNING_THREAD_TID,
                                       values, "Worker Thread Id (TID)")
Example #26
0
    def hook_schedLockServer(self, event, payload):
        timeAcq = event["ts_acquire"]
        cpuId = ExecutionModel.getCurrentCPUId()
        stack = self.getEventStack(event)

        # Emit event in the past. We know that no tracepoint can be emitted
        # between before getting the lock and after the operation completes
        # (at this point as a server). Hence, it is safe the override the
        # standard path and enforce another tracepoint here.
        pastPayload = [(ExtraeEventTypes.RUNTIME_SUBSYSTEMS,
                        self.Status.SchedulerLockEnter)]
        ParaverTrace.emitEvent(timeAcq, cpuId, pastPayload)

        # Emit event at this point in time
        payload.append((ExtraeEventTypes.RUNTIME_SUBSYSTEMS,
                        self.Status.SchedulerLockServing))

        # Add current new status to the event stack
        stack.append(self.Status.SchedulerLockServing)
Example #27
0
 def initialize(cls):
     cls._maxCPUId = ParaverTrace.getMaxRealCPUId()
     cls._ltcpu = ParaverTrace.getLeaderThreadCPUId()
     cls._cpus = [CPU() for i in range(cls._maxCPUId + 1)]
     cls._cpus.append(VCPU())  # Leader Thread CPU
     cls._preHooks = [
         ("nanos6:tc:task_create_enter", cls.hook_taskAdd),
         ("nanos6:oc:task_create_enter", cls.hook_taskAdd),
         ("nanos6:taskfor_init_enter", cls.hook_taskAdd),
         ("nanos6:external_thread_create", cls.hook_externalThreadCreate),
         ("nanos6:thread_create", cls.hook_threadCreate),
         ("nanos6:thread_resume", cls.hook_threadResume),
         ("nanos6:thread_resume", cls.hook_threadResume),
         ("nanos6:task_start", cls.hook_taskStart),
         ("nanos6:task_unblock", cls.hook_taskUnblock),
     ]
     cls._postHooks = [
         ("nanos6:thread_suspend", cls.hook_threadSuspend),
         ("nanos6:task_block", cls.hook_taskBlock),
         ("nanos6:task_end", cls.hook_taskEnd),
     ]
Example #28
0
    def initialize(cls):
        # Load kernel tracepoint definitions file
        try:
            cls.loadKernelDefs("../nanos6_kerneldefs.json")
        except Exception as e:
            return False

        # Initialize hooks
        cls._preHooks = [("sched_switch", cls.hook_schedSwitch)]
        cls._postHooks = []

        # Initialize syscall tracepoitns
        regex = re.compile('^sys\_')
        cls._syscalls = list(filter(regex.match, cls._defs))

        regex = re.compile('^sys\_enter\_')
        cls._syscallEntryPoints = list(filter(regex.match, cls._syscalls))

        regex = re.compile('^sys\_exit\_')
        cls._syscallExitPoints = list(filter(regex.match, cls._syscalls))

        # Initialize CPUs
        maxCPUId = ParaverTrace.getMaxRealCPUId()
        cls._cpus = [CPU(cpuId) for cpuId in range(maxCPUId + 1)]

        # Initialize thread list with a fake Idle thread shared by all Cores
        # (all idle threads in the Linux Kernel have tid 0)
        cls._threads[0] = Thread(0, "Idle", 0)

        # Register the traced application's name to ensure that it always gets
        # the same perProcessExtraeId
        binaryName = ParaverTrace.getBinaryName()
        shortBinaryName = binaryName[:15]
        cls._processNames[shortBinaryName] = 1
        cls._processNameId = 100

        cls._enabled = True

        return cls._enabled
Example #29
0
 def hook_taskLabel(self, event, _):
     source = event["source"]
     taskTypeID = event["type"]
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNNING_TASK_SOURCE,
                                       {taskTypeID: source})
Example #30
0
 def hook_taskLabel(self, event, _):
     label = event["label"]
     taskTypeID = event["type"]
     ParaverTrace.addEventTypeAndValue(ExtraeEventTypes.RUNNING_TASK_LABEL,
                                       {taskTypeID: label})