Skip to content

Generate Multiple Kernels with Single Pragma #5

@shibizhao

Description

@shibizhao

Hi,
I am a beginner of the CCF framework.
I wrote a simple program vadd below:

int kernel(){
	static int _VecAdd2d_buffer[128*128*1] = {};
	static int _inputa_buffer[128*128*1] = {};
	static int _inputb_buffer[128*128*1] = {};
	for(int init_idx = 0; init_idx < (128*128*1); ++init_idx){
		_VecAdd2d_buffer[init_idx] = init_idx + 1;
	}
	for(int init_idx = 0; init_idx < (128*128*1); ++init_idx){
		_inputa_buffer[init_idx] = init_idx + 2;
	}
	for(int init_idx = 0; init_idx < (128*128*1); ++init_idx){
		_inputb_buffer[init_idx] = init_idx + 3;
	}
	stage_0:{
		const int const5 = 0;
		const int const6 = 128;
		for(int incre8 = const5; incre8 < const6; ++incre8){
			const int const9 = 128;
			auto mul10 = incre8 * const9;
			const int const7 = 128;
			auto mul11 = const7 * incre8;
			const int const3 = 0;
			const int const4 = 128;
			#pragma CGRA
			for(int incre12 = const3; incre12 < const4; ++incre12){
				auto add13 = mul10 + incre12;
				auto add14 = mul11 + incre12;
				auto add15 = _inputa_buffer + add13;
				auto load16 = *(add15);
				auto add17 = _inputb_buffer + add13;
				auto load18 = *(add17);
				auto add19 = load16 + load18;
				auto add20 = _VecAdd2d_buffer + add14;
				*(add20) = add19;
			}
		} 
	}
	int _results = 0;
	for(int init_idx = 0; init_idx < (128*128*1); ++init_idx){
		_results += (int)_VecAdd2d_buffer[init_idx];
	}
	for(int init_idx = 0; init_idx < (128*128*1); ++init_idx){
		_results += (int)_inputa_buffer[init_idx];
	}
	for(int init_idx = 0; init_idx < (128*128*1); ++init_idx){
		_results += (int)_inputb_buffer[init_idx];
	}
	return _results;
}

int main(){
	kernel();
	return 0;
}

The CGRA pragma is added at loop-incre12. However, there are two loops in my CGRAExec directory.
Look forward to your reply!
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions