Skip to content

Commit 7515e88

Browse files
authored
Merge pull request #1 from hsamuelson/ParallelDev
Parallel dev
2 parents 53df4fc + fdf6c28 commit 7515e88

2 files changed

Lines changed: 54 additions & 21 deletions

File tree

interpreter.R

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,41 +91,67 @@ Piper <- function(firstFunc, secondFunc){
9191

9292
}
9393
master <- function(){
94+
#
95+
# This is the parallel version 7/26/18
96+
#
97+
# Instead of normally reading through the script while processing,
98+
# this loop reads through the script and compiles a new script which
99+
# is comprized of only function calls and interOp operations. This list
100+
# Is then run in parallel.
101+
counter <- 1
102+
funcList <- numeric() # This will be the list of preprocessed functions passed to the foreach()
94103
for(i in 1:length(script)){
95104

96105
# Ignore Spaces
97106
if(length(strsplit(script[i], " ")[[1]]) != 0){ #If its zero then its def a space
98107

99108
headTag <- strsplit(script[i], " ")[[1]]
100-
101-
#Process function call
102-
#
103-
# THis the main function runner #####
104-
#
105-
# ############
109+
106110
if(headTag[1] == "**"){ #function decloration syntax
107-
108-
#Run function
109-
funcName <- headTag[2]
110-
allBoundsIndex <- match(funcName, allbounds[,3])
111-
if(length(headTag) == 3){
112-
output <- processFunction(allBoundsIndex, argument = headTag[3])
113-
} else {
114-
output <- processFunction(allBoundsIndex)
115-
}
116-
print(output)
117-
111+
funcList[counter] <- script[i]
112+
counter = counter + 1
118113
}
119-
################
114+
120115
if(length(headTag) == 3){
121116
if(headTag[2] == "**<<"){
122-
#Then we need to pass both func bounds
123-
#print(headTag)
124-
print(Piper(headTag[3], headTag[1]))
117+
funcList[counter] <- script[i]
118+
counter = counter + 1
125119
}
126120
}
127121
}
128122
}
123+
#parallelLoop
124+
tt <- foreach(i=1:length(funcList)) %do% { # defining this to tt to avoid unwanted console output
125+
126+
headTag <- strsplit(funcList[i], " ")[[1]]
127+
if(headTag[1] == "**"){ #function decloration syntax
128+
129+
#Run function
130+
funcName <- headTag[2]
131+
allBoundsIndex <- match(funcName, allbounds[,3])
132+
if(length(headTag) == 3){
133+
output <- processFunction(allBoundsIndex, argument = headTag[3])
134+
} else {
135+
output <- processFunction(allBoundsIndex)
136+
}
137+
print(output)
138+
139+
}
140+
################
141+
if(length(headTag) == 3){
142+
if(headTag[2] == "**<<"){
143+
#Then we need to pass both func bounds
144+
#print(headTag)
145+
print(Piper(headTag[3], headTag[1]))
146+
}
147+
}
148+
}
129149
}
150+
#start_time <- Sys.time()
130151
master()
152+
#end_time <- Sys.time()
153+
#end_time - start_time
154+
155+
156+
131157

simple.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <stdio.h>
2+
3+
int main()
4+
{
5+
printf("Hello, World! This is a native C program compiled on the command line.\n");
6+
return 0;
7+
}

0 commit comments

Comments
 (0)