Adaptive Computation Ofﬂoading with Task Scheduling Minimizing Reallocation in VANETs

: Computation Ofﬂoading (CO) can accelerate application running through parallel processing. This paper proposes a method called vehicular adaptive ofﬂoading (VAO) in which vehicles in vehicular ad-hoc networks (VANETs) ofﬂoad computationally intensive tasks to nearby vehicles by taking into account the dynamic topology change of VANETs. In CO, task scheduling has a huge impact on overall performance. After representing the precedence relationship between tasks with a directed acyclic graph (DAG), VAO in the CO requesting vehicle assigns tasks to neighbors so that it can minimize the probability of task reallocations caused by connection disruption between vehicles in VANETs. The simulation results showed that the proposed method decreases the number of reallocations by 45.4%, as compared with the well-known task scheduling algorithms HEFT and Max-Min. Accordingly, the schedule length of entire tasks belonging to one application is shortened by 14.4% on average.


Introduction
As artificial intelligence (AI) has attracted much attention, many recent applications in vehicular ad-hoc networks (VANETs) also contain AI algorithms with resource-intensive computational tasks. However, all vehicles may not have enough computing resources to run those computationally intensive tasks, so computation offloading (CO) [1] has been investigated as a promising technique to overcome this resource limitation.
Historically, CO was proposed to lighten the computation overhead of resourceconstrained devices by transferring computational tasks to resource-abundant servers like a cloud. However, since cloud servers are usually located in remote areas, long data transfer time hindered CO from being widely adopted in VANETs. The security concern along the long path from a requesting vehicle to a cloud server could also be another problem. This is why edge computing [2] and fog computing [3] were suggested, which perform computation at edge or fog servers near requesting vehicles.
However, edge or fog servers are in fixed locations, while vehicles move fast, so vehicles might leave the communication range of edge servers even before computation at the edge servers is complete. As a result, requesting vehicles should often receive computation results through multi-hop communication via road side units (RSUs), not directly from the edge servers. This multi-hop communication latency, although it is not as much as the latency from cloud servers, may be intolerable for recent time-sensitive applications, such as autonomous driving.
Therefore, this paper focuses only on offloading to nearby vehicles, instead of to fixed remote servers. CO to nearby vehicles has several advantages as compared with CO to edge servers. First, the distance to other vehicles is usually shorter than the distance to reward for providing services. For instance, blockchain or non-fungible token (NFT) technology can be used to create non-manipulable incentives to reward SVs. Since further discussion on blockchain and NFT is beyond the scope of this paper, we just assume that every vehicle in this paper is willing to cooperate with other vehicles.
The rest of the paper is organized as follows. In Section 2, related works on computation offloading and task scheduling are briefly overviewed. Section 3 presents the system model and Section 4 covers the numerical method to find the near-optimal task schedule in a static environment. The proposed VAO for a dynamic circumstance like VANET is described in detail in Section 5, and the simulation results are given in Section 6. Section 7 concludes this paper.

Related Works
This section overviews the offloading mechanism first, then explains famous task scheduling algorithms based on the DAG.

Computation Offloading
The authors of [1] proposed a deep Q-learning [12] based offloading mechanism for the mobile fog computing environment [1]. In their frameworks, an application is decomposed into basic blocks and offloaded to many devices. They evaluated latency and energy consumption for varying computation demands and a number of devices. MAUI [13], ThinkAir [14], and CloneCloud [15] are the frameworks for offloading to the mobile edge cloud. In the frameworks, the scheduling algorithm decides whether to offload tasks or not and deploys them according to the policy of the cloud. AVE [16] is an ant colony optimization (ACO) [17] based task offloading framework for mobile devices that are connected with each other by dedicated short-range communications (DSRC). It assumes that tasks are context-free, although the tasks of an application are actually tightly connected among themselves. Note that the precedence relationships and data transfer cost between tasks must be considered to optimize the completion time of an application. However, the works mentioned above model an application as one task or multiple context-free tasks.
CO to other devices requires data transfer overhead. The data transfer overhead is important, particularly when devices are connected with a wireless connection, like the vehicular environment. In the worst-case scenario, the data transfer time might overwhelm the task processing time, so several studies focused on reducing this overhead. For example, the authors of [18] proposed a method using federated learning (FL), in which local devices compute a deep learning (DL) model and a data center gathers the model updates. In [19], the authors suggested reducing the data transfer overhead of the FL method by introducing the random client selection mechanism. For that, federated distillation, based on knowledge distillation [20] and data augmentation [21], were adopted. However, the offloading schemes in [18][19][20][21] are very specific and only for deep-learning algorithms, so they cannot be applied to general applications.
OpenVDAP [22] classifies CO-possible services into four categories, (1) real-time diagnosis services, (2) driving assistance services, (3) in-vehicle infotainment services, and (4) third-party application services. It is very important, especially for real-time diagnosis and driving assistance services, to minimize the latency. The total latency of a service is related to the schedule length, but there has not been much work done on shortening the schedule length.

Task Scheduling
Task scheduling is one of the major factors affecting the performance of CO because the length of the schedule determines the total completion time of all tasks. Then, to the best of our knowledge, there have been no task scheduling methods that consider the precedence relationships between tasks in a dynamic topology like VANET. Thus, we introduce two methods, HEFT [7] and Max-Min [8], instead, which are used in a static environment like parallel processing servers.
First, HEFT is a representative scheduling algorithm that considers the relationship between tasks in the form of a DAG, but it is basically for the multi-processor computing environment with very low communication cost between static processors. In HEFT, the earliest finish time (EFT) of each task, when it is executed on every processor, is calculated. For instance, regarding EFT (t i , p j ), the EFT of task t i on processor p j , is computed as: where w ij is the expected execution time of the task t i on processor p j ; avail[j] is the earliest time when p j is ready to execute t i ; pred(t i ) is the set of predecessor tasks of t i ; AFT(t m ) is the actual finish time (AFT) of t m ; and c mi is the data transfer cost from t m to t i . The schedule length is defined as the largest one among AFTs of all tasks: HEFT schedules a set of tasks, T, in a DAG D on a given set of heterogeneous processors P. HEFT computes the average processing cost w i of a task t i and the average communication cost c ij between tasks t i and t j in the given DAG. Then, it calculates the upward ranks of every task in D reversely from an exit task t exit . The upward rank rank u (t i ) is the total cost from task t i to the exit task, defined as: where isu(t i ) is the set of the immediate successors of t i . HEFT sorts the tasks in T in non-increasing order by rank u into the sorted list T . Then, it gets the first task (i.e., the task with the highest rank) t i in T and allocates the task to the minimum EFT processor (i.e., the processor that can finish the task the fastest) using insertion-based scheduling. The insertion-based scheduling inserts t i to the first time slot of p k where the task can be executed. Finally, t i is allocated to the minimum EFT processor p min . Another well-known scheduling method, Max-Min [8], is very simple, considering only the computation power of processors. Max-Min calculates the estimated finish time K ij of a task t i on a processor p j for every task and every processor. Then, Max-Min allocates the task with the largest K ij to the processor that can execute it the fastest. This allocation is repeated until every task is scheduled.
Several recent works [23,24] utilize duplication-based DAG scheduling. The Task Duplication-based Clustering Algorithm (TDCA) [23] improved performance by accurate parameter definition, enhanced clustering, and by considering the chain reaction. On the other hand, Lachesis [24], which is a task duplication-based learning algorithm, uses a convolutional network to parse a DAG and uses a heuristic search algorithm to allocate selected tasks to selected nodes. Although duplication-based scheduling is effective in reducing the schedule length, by maximizing computing resource usage, it cannot work on resource-constraint devices, such as mobile phones and vehicles, since it has to make copies of tasks to idle processors. Table 1 shows the comparison of related works.

Solutions
Task Granularity Network Topology Computation Provider

System Model
Offloading tasks to clouds or other devices allows mobile devices to overcome the limitation on computation resources. However, offloading to the remote cloud is not suitable for real-time applications because of inevitable long latency. Even in the case of edge/fog computing, a fast-moving vehicle can easily go far from the edge/fog server in a short time, resulting in increased latency. According to current vehicular technology trends, we may expect that vehicles are to be equipped with computational resources, such as CPU, memory, and communication capabilities, and will be able to execute applications using their computational resources managed by virtual machine techniques [25,26]. In this environment, a vehicle can request other vehicles to handle its tasks. In modern computer systems, various types of high-performance computing processors, like CPU, graphics processing unit (GPU), neural processing unit (NPU), field programmable gate array (FPGA) utilizing CUDA [27] or OpenCL [28] can be used to process codes. In this paper, regardless of the types of processors, we model the computing power of a vehicle in MIPS (million instructions per second) units.
Vehicles in a VANET communicate with each other via V2V communications, such as DSRC and cellular vehicle-to-everything (C-V2X). After searching for nearby vehicles, an RV requests SVs to execute its tasks. A set of SVs, V s ,is a subset of the set of searched vehicles V (V s ∈ V). Assuming that there is no conflict and fading on wireless channels between vehicles, we consider only the amount of data that should be transferred on each channel. Then, the communication overhead on wireless is usually larger than the wired channel, so the transfer cost should be complemented by reducing the processing cost with the optimized task schedule. Figure 1 compares the efficiency of the task schedules made by HEFT and Max-Min. Suppose that an application consists of five tasks and their precedence relationships can be represented in a DAG as in Figure 1a. In this graph, nodes and edges correspond to tasks and the dependency between two tasks, respectively. If a task t i in a DAG needs the result of another task t k , t k must be finished before the execution of t i . In this case, t k is the predecessor of t i and t i is the successor of t k . An edge of a DAG points from a predecessor to a successor. Figure 1b,c are the Gantt charts of task executions by Max-Min and HEFT. Here, v 1 is an RV and the other two vehicles are SVs; and the computation powers of v 1 , v 2 , and v 3 are 100, 150, and 200 MIPS, respectively. Max-Min and HEFT in v 1 allocate tasks according to their algorithms. As you can see, HEFT made a shorter schedule length than Max-Min by overlapping data transfer time with execution time on SVs. In our experiment, the schedule length of HEFT was shorter than that of Max-Min by 15.3% on average. This is because HEFT computes the explicit rank of each task, in other words, the order of executing each task, in an upward direction from an exit task based on a DAG, while Max-Min does not use a DAG. Therefore, we also adopt the DAG for the proposed method.

System Model
Offloading tasks to clouds or other devices allows mobile devices to overcome the limitation on computation resources. However, offloading to the remote cloud is not suitable for real-time applications because of inevitable long latency. Even in the case of edge/fog computing, a fast-moving vehicle can easily go far from the edge/fog server in a short time, resulting in increased latency. According to current vehicular technology trends, we may expect that vehicles are to be equipped with computational resources, such as CPU, memory, and communication capabilities, and will be able to execute applications using their computational resources managed by virtual machine techniques [25,26]. In this environment, a vehicle can request other vehicles to handle its tasks. In modern computer systems, various types of high-performance computing processors, like CPU, graphics processing unit (GPU), neural processing unit (NPU), field programmable gate array (FPGA) utilizing CUDA [27] or OpenCL [28] can be used to process codes. In this paper, regardless of the types of processors, we model the computing power of a vehicle in MIPS (million instructions per second) units.
Vehicles in a VANET communicate with each other via V2V communications, such as DSRC and cellular vehicle-to-everything (C-V2X). After searching for nearby vehicles, an RV requests SVs to execute its tasks. A set of SVs, ,is a subset of the set of searched vehicles ( ∈ ). Assuming that there is no conflict and fading on wireless channels between vehicles, we consider only the amount of data that should be transferred on each channel. Then, the communication overhead on wireless is usually larger than the wired channel, so the transfer cost should be complemented by reducing the processing cost with the optimized task schedule. Figure 1 compares the efficiency of the task schedules made by HEFT and Max-Min. Suppose that an application consists of five tasks and their precedence relationships can be represented in a DAG as in Figure 1a. In this graph, nodes and edges correspond to tasks and the dependency between two tasks, respectively. If a task in a DAG needs the result of another task , must be finished before the execution of . In this case, is the predecessor of and the successor of . An edge of a DAG points from a predecessor to a successor.
(a)  Here, is an RV and the other two vehicles are SVs; and the computation powers of , , and are 100, 150, and 200 MIPS, respectively. Max-Min and HEFT in allocate tasks according to their algorithms. As you can see, HEFT made a shorter schedule length than Max-Min by overlapping data transfer time with execution time on SVs. In our experiment, the schedule length of HEFT was shorter than that of Max-Min by 15.3% on average. This is because HEFT computes the explicit rank of each task, in other words, the order of executing each task, in an upward direction from an exit task based on a DAG, while Max-Min does not use a DAG. Therefore, we also adopt the DAG for the proposed method.
In this example, the task allocation is decided offline before actual execution, since HEFT and Max-Min were designed for static environments, such as parallel processing servers. However, in VANET, task reallocation must be handled frequently, since the associated SVs may leave the communication range of the RV without returning the computation result.

Problem Formulation
As mentioned earlier, the optimal task allocation problem is NP-hard. However, we can get a near-optimal solution using linear programming.
First, the allocation of is denoted by a binary variable which is set to 1 when is allocated to vehicle , and otherwise, 0: A task schedule χ is represented by a matrix consisting of s': where is the number of SVs and is the number of tasks. For the sake of simplicity, we assume that a vehicle executes only one task at a time and that a task cannot be allocated to more than one vehicle simultaneously. In order to guarantee a task being allocated to only one vehicle, the following condition must be satisfied: A task without any predecessor is called an entry task, and a task without any successor is called an exit task. Only the applications with one entry task are considered in this paper. In this example, the task allocation is decided offline before actual execution, since HEFT and Max-Min were designed for static environments, such as parallel processing servers. However, in VANET, task reallocation must be handled frequently, since the associated SVs may leave the communication range of the RV without returning the computation result.

Problem Formulation
As mentioned earlier, the optimal task allocation problem is NP-hard. However, we can get a near-optimal solution using linear programming.
First, the allocation of t i is denoted by a binary variable x ij which is set to 1 when t i is allocated to vehicle v j , and otherwise, 0: A task schedule χ is represented by a matrix consisting of x ij s': where n v is the number of SVs and n t is the number of tasks. For the sake of simplicity, we assume that a vehicle executes only one task at a time and that a task cannot be allocated to more than one vehicle simultaneously. In order to guarantee a task being allocated to only one vehicle, the following condition must be satisfied: A task without any predecessor is called an entry task, and a task without any successor is called an exit task. Only the applications with one entry task are considered in this paper.
For executing task t i on an SV v j , all of its predecessors must be finished beforehand, and the results from the predecessors must be received by v j . Therefore, ST(t i ), the start time of t i , must satisfy the following condition: where pred(t i ) is the set of the immediate predecessors of t i and c mi is the data transfer cost from t m to t i . Furthermore, because an SV is assumed not to execute more than one task at the same time, ST(t i ) must satisfy the following condition: where AFT(t k ) = ST(t k ) + E kj and alloc(j) is the set of tasks allocated (or offloaded) to v j . The value E kj is the execution time of t k on v j and can be computed as is the data size of t k , ipb(k) is the number of instructions needed to process 1 byte of data in t k , and mips(j) is the computing power of processor j expressed in MIPS.
Assuming that there is no task reallocation, the objective function is: However, a fast-moving SV can be out of the communication range of the RV easily, so unfinished tasks that had been allocated to the SV have to be reallocated to other vehicles. If the set of the tasks that should be reallocated is RT, the objective function is: In the dynamic vehicular environment, the vehicles in the coverage area of a vehicle tend to change frequently. After offloading tasks to SVs, the RV has to continuously track the SVs for possible task reallocation events.

Vehicular Adaptive Offloading (VAO)
While linear optimization on the task schedule is possible in a static environment, a dynamic situation like a VANET requires a heuristic method, since even the information on the service processors is not basically given. This section firstly overviews the operation of our method of VAO, then explains the proposed task scheduling and task reallocation scheme in detail. Figure 2 shows the operation of VAO. First, an RV v r searches for nearby vehicles and collects their information, such as computing power and route, by broadcasting a message.

Operation Overview
Then v r assigns computational tasks to nearby vehicles according to the task schedule it makes, based on neighbor vehicle information. After that, it periodically checks whether SVs will be out of its communication range soon, and in that case, unfinished tasks on the SVs are reallocated to other vehicles. This procedure is depicted in Algorithm 1. Before delving into the algorithm, see Table 2 for the notations.

Notation
Meaning a directed acyclic graph a set of searched vehicles  an SV that can provide the minimum EFT for a task T a set of the tasks t i a task t exit an exit task χ a matrix of a task schedule for every task t i in T 10 transfer t i to the vehicles in V S according to χ 11 remove t i from T 12 end for 13 start/resume execution of the application by transferring the input data 14 T ← check_realloc (V S ) 15 until all SVs complete the allocated tasks Algorithm 1 describes the operation of VAO in an RV v r . After initialization, v r conducts a search broadcasting a vehicle information request (VIRQ) message, and each vehicle receiving this message sends a vehicle information reply (VIRP) with the information on its route and computing resources (Line 6). The searched vehicle information is stored into V (Line 7), then v r calls up the task scheduling algorithm to determine χ based on the information on the set of the tasks T and the computing power of vehicles in V (Line 8). This task scheduling algorithm is described in Algorithm 2 in the next section. Then, v r transfers tasks in T to the vehicles in V S according to χ (Line 9 to 12). Then, in Line 13, v r starts to execute the application by transferring input data to the SVs that have entry tasks.
After completing its allocated tasks, an SV transmits the result to the SVs that have successor tasks. However, in a VANET where vehicles move fast, SVs may frequently leave the communication range of the RV before completing their work, and this can cause a big problem in the CO system because all successor tasks cannot be executed until they receive the results of predecessor tasks. Therefore, we need to reallocate the tasks associated with original SVs that have gone far away without completing the task. If any SV not finishing its assigned tasks has gone too far apart from v r , those tasks are reallocated to other nearby vehicles. This check and reallocation are periodically done until all offloaded tasks are complete. The detailed procedure will be explained in Section 5.3.

Task Scheduling
The proposed task scheduling method has two important features: first, it utilizes the DAG to consider the precedence relationships between tasks, and, second, it selects only nearby vehicles whose routes are similar to the route of RV as SVs, in order to reduce the Electronics 2022, 11, 1106 9 of 16 chance of task reallocation. As mentioned earlier, a task schedule χ is the most important factor affecting performance, since a long task schedule means a long execution time. In general, the more reallocations that occur, the longer the task schedule is.

Algorithm 2: task schedule (T, V)
Input: a given DAG D, a set of tasks T in D, a set of searched vehicles V Output: task schedule χ 1 compute average processing and communication cost 2 calculate rank u of every task in D in an upward direction, starting from an exit task 3 let T be the list of tasks in T, sorted in non-increasing order by rank u 4 V f ← { v i |v i ∈ V and its route overlaps the route of v r by more than α blocks} 5 while there exist tasks in T do 6 t i ← the first task in T 7 for v k in V f do 8 calculate the EFT (t i , v k ) with insertion-based scheduling 9 end for 10 allocate t i to the minimum EFT vehicle v min 11 remove t i from T 12 end while Lines 1 to 2 compute the average cost of searched vehicles and the rank u of every task in an upward direction from an exit task. Line 3 sorts the tasks in non-increasing order by rank u . Then, in Line 4, out of the searched vehicles, only vehicles whose routes overlap the route of v r by more than α blocks are filtered into a new set of vehicles V f . Only vehicles in V f are considered as a candidate SV that can provide the minimum EFT for each task in subsequent lines. Line 6 gets the first task in the sorted list T into t i . In Lines 7 to 9, v r calculates the EFT of t i on every v k in V f with insertion-based scheduling. Line 10 allocates t i to the vehicle that can provide the minimum EFT. Lines 6 to 11 are repeated while there exist any unallocated tasks.

Check Reallocation
Although our scheduling method tries its best to avoid task reallocation, this cannot be perfectly avoided because of the dynamic topology change in VANETs. The following Algorithm 3 shows how VAO handles task reallocation caused by the connection disruption topology change makes. request v s to transfer the stored data for the tasks 6 end if 7 return T In Line 1, an RV v r periodically broadcasts its location information to SVs, then SVs which are expected to be out of communication range send report messages to v r . In Lines 2 to 6, all SVs are informed of a task reallocation event if any v s is expected to be out of range. All the SVs stop data transfer to v s and v r requests v s to transfer stored data for the tasks. After that, the algorithm returns the set of unfinished tasks, so Algorithm 1 can reallocate the tasks.
To filter out the vehicles, Algorithm 2 needs to compare every route of the searched vehicles with that of RV. The time complexity of comparing the routes is O (α|V|) when the number of the searched vehicles is |V|. The time complexity of finding the first idle time slot is O (|T| 2 |V|). So, the total complexity of the VAO is O (|T| 2 |V|).

Performance Evaluation
Using the Veins network simulator [6], we compared the performances of VAO, HEFT, and Max-Min in terms of schedule length, reallocation probability, and data transfer time. Actually, since neither HEFT nor Max-Min include a way to reallocate tasks, the VIRQ/VIRP process of VAO was adopted for the HEFT and Max-Min task reallocation. So, the message overheads of the three methods are naturally the same. In VAO, α was set to 3 empirically, or only neighbor vehicles whose routes overlap the route of the RV for more than 3 blocks were selected as candidate SVs. When α was greater than 3, performance dropped because of the scarce number of candidate SVs. When α was smaller than 3, the chance of task reallocation rarely decreased, as compared with HEFT.
We first compared the schedule length by each algorithm and observed the effects of data transfer time and the number of SVs on the overall performance. Then, the reallocation probability of each algorithm is investigated. Finally, the effect of the depth of width of a DAG on performance is studied. Figure 3 shows the DAG representation of an offloaded application used for the simulation, with both depth and width of 4. The depth and width mean the total number of levels in a DAG and the maximum number of nodes in one level, respectively. The road structure is shown in Figure 4. A total of 100~300 vehicles, which is proportional to the simulation time, with a maximum speed of 30 km/h were randomly deployed on the roads. Each of them followed one of 30 routes that were randomly generated, and its processing power followed uniform distribution between 200 and 600 MIPS.  The road structure is shown in Figure 4. A total of 100~300 vehicles, which is proportional to the simulation time, with a maximum speed of 30 km/h were randomly deployed on the roads. Each of them followed one of 30 routes that were randomly generated, and its processing power followed uniform distribution between 200 and 600 MIPS. Figure 5 compares the average schedule length over 1000 simulations for an application that can be represented by a DAG with both depth and width of 4. As mentioned in Section 3, the schedule length by HEFT was 15.3% shorter than Max-Min, since HEFT makes the schedule considering relationships between tasks of an application, which is represented in a DAG. On the other hand, VAO created schedules 11.7% longer than HEFT, although VAO also utilizes a DAG. This is because VAO filters out some searched vehicles from the set of candidate SVs, based on how long their routes overlap the route of the RV. The smaller the number of candidate SVs, the smaller the number of tasks that can be executed in parallel. Furthermore, if some vehicles with high computing power are excluded from the candidate SVs' set, the total computing capability of the offloading system would be degraded. More experiments were needed to better understand these results. The road structure is shown in Figure 4. A total of 100~300 vehicles, which is proportional to the simulation time, with a maximum speed of 30 km/h were randomly deployed on the roads. Each of them followed one of 30 routes that were randomly generated, and its processing power followed uniform distribution between 200 and 600 MIPS.  Figure 5 compares the average schedule length over 1000 simulations for an application that can be represented by a DAG with both depth and width of 4. As mentioned in Section 3, the schedule length by HEFT was 15.3% shorter than Max-Min, since HEFT makes the schedule considering relationships between tasks of an application, which is represented in a DAG. On the other hand, VAO created schedules 11.7% longer than HEFT, although VAO also utilizes a DAG. This is because VAO filters out some searched vehicles from the set of candidate SVs, based on how long their routes overlap the route of the RV. The smaller the number of candidate SVs, the smaller the number of tasks that can be executed in parallel. Furthermore, if some vehicles with high computing power are excluded from the candidate SVs' set, the total computing capability of the offloading system would be degraded. More experiments were needed to better understand these results. We performed additional simulations 1000 times with various densities of vehicles so that the number of searched vehicles could be different. Figure 6a depicts the schedule length against the number of searched vehicles | |. When | | was 0, tasks could not be offloaded (no CO happened); and when | | became 1, the schedule lengths of HEFT and Max-Min decreased by 39.4%. As | | increased, the schedule length typically decreased, but after | | was greater than 4, the schedule lengths by HEFT and Max-Min were stable around 41.7% and 49.1% of the no CO case. This is because the width of the DAG for our application was 4. Since up to four tasks can be executed simultaneously in a level, many more vehicles than 4 are not much help to improve parallel computing efficiency. However, in the case of VAO, about twice as many searched vehicles were needed to stabilize the performance because some of the searched vehicles were excluded from the candidate SVs' set, due to their different routes from the RV's route. Figure 6b shows the schedule length when the number of searched vehicles | | is sufficient. When | | is large enough, the schedule lengths by HEFT and Max-Min do not change much. On the other hand, the schedule length by VAO continuously decreases as | | increases. We performed additional simulations 1000 times with various densities of vehicles so that the number of searched vehicles could be different. Figure 6a depicts the schedule length against the number of searched vehicles |V|. When |V| was 0, tasks could not be offloaded (no CO happened); and when |V| became 1, the schedule lengths of HEFT and Max-Min decreased by 39.4%. As |V| increased, the schedule length typically decreased, but after |V| was greater than 4, the schedule lengths by HEFT and Max-Min were stable around 41.7% and 49.1% of the no CO case. This is because the width of the DAG for our application was 4. Since up to four tasks can be executed simultaneously in a level, many more vehicles than 4 are not much help to improve parallel computing efficiency. However, in the case of VAO, about twice as many searched vehicles were needed to stabilize the performance because some of the searched vehicles were excluded from the candidate SVs' set, due to their different routes from the RV's route. Figure 6b shows the schedule length when the number of searched vehicles |V| is sufficient. When |V| is large enough, the schedule lengths by HEFT and Max-Min do not change much. On the other hand, the schedule length by VAO continuously decreases as |V| increases. Figure 6c shows the number of SVs according to the number of searched vehicles. Actually, we can see that the number of vehicles that provide computation services in HEFT became equal to the number of SVs in HEFT when the number of searched vehicles was 8, which is twice the width of the DAG. This means if there are sufficient vehicles, VAO can give good performance.
The accumulated data transfer times during the execution of an application are presented in Figure 6d. While the data transfer time of Max-Min continuously increased, the data transfer times of HEFT and VAO barely increased once stable. This is because Max-Min considers only computation power of vehicles in selecting SVs, resulting in task offloading to an unnecessarily excessive number of SVs as |V| increases. On the contrary, HEFT and VAO select SVs considering data transfer time as well as computation power of vehicles in (1) and (3). Thus, although a neighbor vehicle has a little higher computation power, an RV does not offload tasks to the neighbor if the data transfer cost is too high.
As seen in Figure 5, the initial schedule length by VAO is slightly longer than HEFT if there are not enough vehicles around an RV because some neighbor vehicles are excluded from the candidate SVs' set. However, in terms of reallocation overhead, VAO is better than others. Figure 7 compares the task reallocation probability of the three methods. This result comes from the same simulations in Figure 6. Only 15.2% of tasks were reallocated to others in VAO, whereas 60.6% and 86.2% of tasks had to be reallocated to others in HEFT and Max-Min, respectively. As a result, the schedule length by VAO, including reallocated tasks, was shorter than HEFT by 14.4%, although the initial schedule length by VAO was 11.7% longer than HEFT.
The performance of the CO scheme can be different according to the depth and width of a DAG. Figure 8a,b illustrate initial schedule lengths associated with varying the depth and width of a DAG. While one of the width and depth was varied, the other was fixed at 4. In both graphs, as the depth or the width increases, the length of the schedules increases naturally, since the total number of tasks increases.
Comparing "large depth" to "large width", the large width was better to create shorter schedule lengths because more tasks can be executed in parallel on more SVs. Figure 8b shows that Max-Min is also a good option in the case where the width is large. However, the width of a DAG can be widened only when tasks have no tight relationships with each other. If tasks have strict precedence relationships between themselves, only the depth can increase. Figure 8a shows that the schedule length difference between Max-Min and the other methods got bigger as the depth of a DAG increased. When the depth was 8, the schedule length difference between HEFT and Max-Min was 14.8 s, 7.7 times larger than the difference when the depth was 2. This substantiates the view that DAG scheduling is efficient for applications with a large depth.
Electronics 2022, 11, x FOR PEER REVIEW 12 of 1 Figure 5. Initial schedule length without reallocation for a depth 4 and width 4 DAG application.
We performed additional simulations 1000 times with various densities of vehicle so that the number of searched vehicles could be different. Figure 6a depicts the schedul length against the number of searched vehicles | |. When | | was 0, tasks could not b offloaded (no CO happened); and when | | became 1, the schedule lengths of HEFT an Max-Min decreased by 39.4%. As | | increased, the schedule length typically decreased but after | | was greater than 4, the schedule lengths by HEFT and Max-Min were stabl around 41.7% and 49.1% of the no CO case. This is because the width of the DAG for ou application was 4. Since up to four tasks can be executed simultaneously in a level, man more vehicles than 4 are not much help to improve parallel computing efficiency However, in the case of VAO, about twice as many searched vehicles were needed t stabilize the performance because some of the searched vehicles were excluded from th candidate SVs' set, due to their different routes from the RV's route. Figure 6b shows th schedule length when the number of searched vehicles | | is sufficient. When | | is larg enough, the schedule lengths by HEFT and Max-Min do not change much. On the othe hand, the schedule length by VAO continuously decreases as | | increases.  The accumulated data transfer times during the execution of an application ar  Figure 7 compares the task reallocation probability of the three methods. This result comes from the same simulations in Figure 6. Only 15.2% of tasks were reallocated to others in VAO, whereas 60.6% and 86.2% of tasks had to be reallocated to others in HEFT and Max-Min, respectively. As a result, the schedule length by VAO, including reallocated tasks, was shorter than HEFT by 14.4%, although the initial schedule length by VAO was 11.7% longer than HEFT. The performance of the CO scheme can be different according to the depth and width of a DAG. Figure 8a,b illustrate initial schedule lengths associated with varying the depth and width of a DAG. While one of the width and depth was varied, the other was fixed at 4. In both graphs, as the depth or the width increases, the length of the schedules increases naturally, since the total number of tasks increases.   The performance of the CO scheme can be different according to the depth and width of a DAG. Figure 8a,b illustrate initial schedule lengths associated with varying the depth and width of a DAG. While one of the width and depth was varied, the other was fixed at 4. In both graphs, as the depth or the width increases, the length of the schedules increases naturally, since the total number of tasks increases.   Figure 9 represents the data transfer time with varying depth and width. Figure 9a shows the data transfer time of Max-Min was longer than that of HEFT and VAO by 18~20%. Meanwhile, Figure 9b shows that the data transfer times of HEFT and Max-Min became closer as width increased, and the difference was just 5.8% when the width was 8. Anyway, in both graphs, VAO outperformed the two other methods, since it selects a relatively smaller number of SVs, taking both their routes and data transfer time into account. Comparing "large depth" to "large width", the large width was better to create shorter schedule lengths because more tasks can be executed in parallel on more SVs. Figure 8b shows that Max-Min is also a good option in the case where the width is large. However, the width of a DAG can be widened only when tasks have no tight relationships with each other. If tasks have strict precedence relationships between themselves, only the depth can increase. Figure 8a shows that the schedule length difference between Max-Min and the other methods got bigger as the depth of a DAG increased. When the depth was 8, the schedule length difference between HEFT and Max-Min was 14.8 s, 7.7 times larger than the difference when the depth was 2. This substantiates the view that DAG scheduling is efficient for applications with a large depth. Figure 9 represents the data transfer time with varying depth and width. Figure 9a shows the data transfer time of Max-Min was longer than that of HEFT and VAO by 18~20%. Meanwhile, Figure 9b shows that the data transfer times of HEFT and Max-Min became closer as width increased, and the difference was just 5.8% when the width was 8. Anyway, in both graphs, VAO outperformed the two other methods, since it selects a relatively smaller number of SVs, taking both their routes and data transfer time into account.

Conclusions
We proposed vehicular adaptive offloading (VAO) for the dynamic vehicular environment, which uses DAG scheduling for optimizing task execution. Unlike other well-known scheduling methods, HEFT and Max-Min, VAO focuses on reducing task

Conclusions
We proposed vehicular adaptive offloading (VAO) for the dynamic vehicular environment, which uses DAG scheduling for optimizing task execution. Unlike other well-known scheduling methods, HEFT and Max-Min, VAO focuses on reducing task reallocation, taking into account the dynamic topology of VANETs. For that purpose, VAO does not offload tasks to neighbors whose routes are much different from the RV's route. The simulation results showed that VAO decreases the probability of task reallocation by 45.4%, as compared with HEFT. Our simulation reveals that more SVs are required than the width of DAG to optimize CO but many more vehicles than the width are not helpful. When the number of searched vehicles is sufficient, the schedule length of VAO, including all reallocated tasks, is 14.4% shorter than that of HEFT.
We have two future works. First, during the simulation, we occasionally observed that the schedule length of a task set increased when CO was used, as compared with the case where all the tasks were performed in one vehicle. This is mainly because of unexpected task reallocation events, so, if we can predict the chance of task reallocation occurring, inefficient CO can be avoided. We think that AI methods like LSTM (Long Short-Term Memory), which can analyze time-series data on number and distribution of vehicles, might be helpful to predict task reallocation events. Second, we did not consider the situation where multiple vehicles request CO at the same time, resulting in possible conflict at their shared nearby vehicles. This might be solved if a nearby vehicle informs each CO RV of the computing power that can be provided to the RV exclusively. Table 3 summarizes the characteristics of the algorithms observed in this paper. Table 3. Characteristics of task scheduling algorithms.