Skip to content

Instantly share code, notes, and snippets.

@xspager
Created August 9, 2016 05:54
Show Gist options
  • Save xspager/65e04abc3751f4c58cd84782fcf31936 to your computer and use it in GitHub Desktop.
Save xspager/65e04abc3751f4c58cd84782fcf31936 to your computer and use it in GitHub Desktop.
local C = terralib.includec("stdio.h")
local intel_x86_target = terralib.newtarget {
Triple = "x86_64-apple-darwin";
-- CPU = ;
Features = "+sse,+mmx";
}
struct Person {
age: int
}
terra main()
C.printf("Hello :)\n")
var people: Person[10000]
var buff: (&Person)[10000]
var i = 10 / 1000
for x = 0, 10000 do
people[x].age = i + 2*x
C.printf("%d\n", i)
end
for x = 0, 10000 do
buff[x] = &people[x]
end
for x = 0, 10000 do
buff[x].age = buff[x].age / 4
end
for x = 0, 10000 do
C.printf("%d\n", buff[x].age)
end
end
terralib.saveobj("target.o", {main=main}, {}, intel_x86_target)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment