PARALLEL PROCESSING OF AN EXPRESSION
A method includes compiling an expression into executable code that is configured to create a data structure that represents the expression. The expression includes a plurality of sub-expressions. The code is executed to create the data structure. The data structure is evaluated using a plurality of concurrent threads, thereby processing the expression in a parallel manner.
1 . A computer-readable storage medium storing computer-executable instructions for performing a method comprising:
compiling an expression into executable code that is configured to create a data structure that represents the expression, wherein the expression includes a plurality of sub-expressions;
executing the code to create the data structure; and
evaluating the data structure using a plurality of concurrent threads, thereby processing the expression in a parallel manner.
2 . The computer-readable storage medium of claim 1 , wherein the data structure is an expression tree.
3 . The computer-readable storage medium of claim 1 , wherein evaluating the data structure comprises:
evaluating at least one of the sub-expressions with an asynchronous task.
4 . The computer-readable storage medium of claim 3 , wherein the asynchronous task is a future.
5 . The computer-readable storage medium of claim 1 , wherein evaluating the data structure comprises:
identifying a computational cost for each of the sub-expressions; and
determining for each sub-expression whether to evaluate the sub-expression with an asynchronous task based on the identified cost of the sub-expression.
6 . The computer-readable storage medium of claim 5 , wherein the computational cost for at least one of the sub-expressions is expressed in the sub-expression by a user.
7 . The computer-readable storage medium of claim 5 , wherein the computational cost for at least one of the sub-expressions is identified automatically based on heuristics.
8 . The computer-readable storage medium of claim 5 , wherein the computational cost for at least one of the sub-expressions is identified automatically based on a method signature of the sub-expression.
9 . The computer-readable storage medium of claim 1 , wherein evaluating the data structure comprises:
identifying each sub-expression as one of computationally expensive or computationally inexpensive.
10 . The computer-readable storage medium of claim 9 , wherein evaluating the data structure further comprises:
evaluating each computationally inexpensive sub-expression with a main thread; and
concurrently evaluating at least one of the computationally expensive sub-expressions with at least one additional thread.
11 . The computer-readable storage medium of claim 1 , wherein evaluating the data structure comprises:
identifying a sub-expression that can be evaluated using an asynchronous programming pattern method; and
evaluating the identified sub-expression using the asynchronous programming pattern method.
12 . The computer-readable storage medium of claim 1 , wherein the method further comprises:
measuring an amount of time spent evaluating at least one of the sub-expressions; and
adjusting evaluation of the at least one sub-expression based on the measured amount of time.
13 . A method of evaluating an expression in a parallel manner, the expression including a plurality of sub-expressions, the method comprising:
providing executable code that is configured to create a data structure that represents the expression;
executing the code to create the data structure; and
evaluating the data structure using a plurality of concurrent threads, thereby processing the expression in a parallel manner.
14 . The method of claim 13 , wherein the data structure is an expression tree.
15 . The method of claim 13 , wherein evaluating the data structure comprises:
evaluating at least one of the sub-expressions with an asynchronous task.
16 . The method of claim 15 , wherein the asynchronous task is a future.
17 . The method of claim 13 , wherein evaluating the data structure comprises:
identifying each sub-expression as one of computationally expensive or computationally inexpensive.
18 . The method of claim 17 , wherein evaluating the data structure further comprises:
evaluating each computationally inexpensive sub-expression with a main thread; and
concurrently evaluating at least one of the computationally expensive sub-expressions with at least one additional thread.
19 . A computer-readable storage medium storing computer-executable instructions for performing a method comprising:
compiling an expression into executable code that is configured to create a data structure that represents the expression;
executing the code to create the data structure;
evaluating a first portion of the data structure using a first thread; and
concurrently evaluating a second portion of the data structure using a second thread.
20 . The computer-readable storage medium of claim 19 , wherein the data structure is an expression tree.