blob: 18a9ead4bc3fe159ba39241b56392c6363987150 [file] [log] [blame]
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------
X = rand(rows=10000, cols=1000, seed=42);
y = rand(rows=10000, cols=1000, seed=43);
S = matrix(0, rows=1, cols=3);
for (j in 1:2) {
X1 = X;
y1 = y;
S1 = 0;
# fill half of the cache
for (i in 1:20) {
R = X1 * y1;
X1 = cbind(X1, rand(rows=10000, cols=1, seed=42));
y1 = cbind(y1, rand(rows=10000, cols=1, seed=42));
while(FALSE){}
S1 = S1 + sum(R);
}
}
S[,1] = S1;
X2 = X;
y2 = y;
S2 = 0;
# reuse (saves cache pollution)
for (i in 1:20) {
R = X2 * y2;
X2 = cbind(X2, rand(rows=10000, cols=1, seed=42));
y2 = cbind(y2, rand(rows=10000, cols=1, seed=42));
while(FALSE){}
S2 = S2 + sum(R);
}
S[,2] = S2;
# generate eviction
for (i in 1:20) {
R = X1 * y1;
X1 = cbind(X1, rand(rows=10000, cols=1, seed=42));
y1 = cbind(y1, rand(rows=10000, cols=1, seed=42));
while(FALSE){}
S1 = S1 + sum(R);
}
S[,3] = S1;
write(S, $1, format="text");