I tried to use #pragma in DSL, but an error has occured.
For example, I inserted #pragma unroll 2 in the second line of
sample/c++/Nbody/kernel.pikg.
F64 eps2
#pragma unroll 2
rij = EPI.pos - EPJ.pos
r2 = rij * rij + eps2
r_inv = rsqrt(r2)
r2_inv = r_inv * r_inv
mr_inv = EPJ.mass * r_inv
mr3_inv = r2_inv * mr_inv
FORCE.acc -= mr3_inv * rij
FORCE.pot -= mr_inv
Then, I ran make and got the following error message.
conversion type: reference
epi name: Particle
epj name: Particle
force name: Particle
class file: particle.hpp
output file name: kernel.hpp
input file: kernel.pikg
/home/tom/pikg/src/gen_hash.rb:20:in `block (2 levels) in fusion_iotag': undefined method `fusion_iotag' for #<Pragma:0x0000558cf91a1dd8 @name="unroll", @option=["2"]> (NoMethodError)
from /home/tom/pikg/src/gen_hash.rb:19:in `each'
from /home/tom/pikg/src/gen_hash.rb:19:in `block in fusion_iotag'
from /home/tom/pikg/src/gen_hash.rb:18:in `each'
from /home/tom/pikg/src/gen_hash.rb:18:in `fusion_iotag'
from /home/tom/pikg/src/gen_hash.rb:313:in `generate_alias'
from /home/tom/pikg/src/parserdriver.rb:1681:in `<top (required)>'
from ../../..//bin/pikg:2:in `require_relative'
from ../../..//bin/pikg:2:in `<main>'
make: *** [Makefile:50: kernel.hpp] Error 1
If we add the following fusion_iotag method to the Pragma class, the error will no longer occur, but the generated kernel will not be changed by #pragma.
def fusion_iotag(iotag)
[]
end
|
class Pragma |
|
attr_accessor :name, :option |
|
def initialize(x) |
|
@name,@option = x |
|
end |
|
|
|
def get_related_variable |
|
[] |
|
end |
|
|
|
def declare_temporal_var |
|
[] |
|
end |
|
|
|
def convert_to_code(conversion_type="reference") |
|
ret = String.new |
|
if conversion_type != "reference" |
|
ret = "#pragma #{@name}" |
|
if @option != nil then |
|
@option.each{ |x| |
|
ret += " #{x}" |
|
} |
|
end |
|
end |
|
ret |
|
end |
|
end |
I tried to use
#pragmain DSL, but an error has occured.For example, I inserted
#pragma unroll 2in the second line ofsample/c++/Nbody/kernel.pikg.Then, I ran
makeand got the following error message.If we add the following
fusion_iotagmethod to thePragmaclass, the error will no longer occur, but the generated kernel will not be changed by#pragma.PIKG/src/intermediate_exp_class.rb
Lines 754 to 780 in 751ef58