Skip to content

Commit

Permalink
added program template demonstrating how to validate numerical output…
Browse files Browse the repository at this point in the history
… with threshold!
  • Loading branch information
gfursin committed May 25, 2018
1 parent 7808b01 commit fcf1b27
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/.cm/alias-a-icc-15.0
@@ -0,0 +1 @@
890074521935414f
1 change: 1 addition & 0 deletions compiler/.cm/alias-u-890074521935414f
@@ -0,0 +1 @@
icc-15.0
54 changes: 54 additions & 0 deletions compiler/icc-15.0/.cm/desc.json
@@ -0,0 +1,54 @@
{
"all_compiler_flags_desc": {
"##base_opt": {
"choice": [
"-O3",
"-fast",
"-O0",
"-O1",
"-O2",
"-Os"
],
"default": "",
"desc": "base compiler flag",
"sort": 10000,
"tags": [
"base",
"basic",
"optimization"
],
"type": "text"
},
"##global_loop_unrolling": {
"can_omit": "yes",
"default": "",
"desc": "compiler flag: -Qunroll",
"explore_prefix": "-Qunroll",
"explore_start": 1,
"explore_step": 1,
"explore_stop": 32,
"sort": 10100,
"tags": [
"basic",
"optimization"
],
"type": "integer"
},
"##openmp": {
"can_omit": "yes",
"choice": [
"-openmp",
""
],
"default": "",
"desc": "compiler flag: openmp",
"sort": 10001,
"tags": [
"basic",
"openmp",
"optimization"
],
"type": "text"
}
}
}
29 changes: 29 additions & 0 deletions compiler/icc-15.0/.cm/info.json
@@ -0,0 +1,29 @@
{
"backup_data_uid": "890074521935414f",
"backup_module_uid": "36ebc331048475bb",
"backup_module_uoa": "compiler",
"cm_outdated": {
"cm_access_control": {
"comments_groups": "admin",
"read_groups": "all",
"write_groups": "owner"
},
"powered_by": {
"name": "Collective Mind Engine",
"version": "1.0.1977.beta"
}
},
"control": {
"author_uoa": "74c2480dcec9e85d",
"engine": "CM",
"iso_datetime": "2017-10-11T16:56:43.931214",
"version": [
"1",
"9",
"2",
"1"
]
},
"data_name": "icc-15.0",
"description": ""
}
9 changes: 9 additions & 0 deletions compiler/icc-15.0/.cm/meta.json
@@ -0,0 +1,9 @@
{
"tags": [
"compiler",
"icc",
"v15",
"v15.0",
"auto"
]
}
@@ -0,0 +1 @@
08ef407b9ce82e10
1 change: 1 addition & 0 deletions program/.cm/alias-u-08ef407b9ce82e10
@@ -0,0 +1 @@
template-hello-world-c-output-validation
6 changes: 6 additions & 0 deletions program/template-hello-world-c-openme/preprocess.py
Expand Up @@ -17,6 +17,12 @@ def ck_preprocess(i):
rt=i['run_time']
deps=i['deps']

ck.out('***********************************')
ck.out('Resolved deps via CK:')
ck.out('')
ck.out(json.dumps(deps, indent=2))
ck.out('***********************************')

env=i['env']
nenv={} # new environment to be added to the run script

Expand Down
@@ -0,0 +1 @@
{}
21 changes: 21 additions & 0 deletions program/template-hello-world-c-output-validation/.cm/info.json
@@ -0,0 +1,21 @@
{
"backup_data_uid": "08ef407b9ce82e10",
"backup_module_uid": "b0ac08fe1d3c2615",
"backup_module_uoa": "program",
"control": {
"author": "Grigori Fursin",
"author_email": "Grigori.Fursin@cTuning.org",
"author_webpage": "http://fursin.net",
"copyright": "See CK COPYRIGHT.txt for copyright details",
"engine": "CK",
"iso_datetime": "2018-05-25T14:56:27.497199",
"license": "See CK LICENSE.txt for licensing details",
"version": [
"1",
"9",
"4",
"1"
]
},
"data_name": "C program \"Hello world\" with output validation"
}
58 changes: 58 additions & 0 deletions program/template-hello-world-c-output-validation/.cm/meta.json
@@ -0,0 +1,58 @@
{
"backup_data_uid": "08ef407b9ce82e10",
"build_compiler_vars": {},
"compile_deps": {
"compiler": {
"local": "yes",
"name": "C compiler",
"tags": "compiler,lang-c"
}
},
"compiler_env": "CK_CC",
"data_name": "template-hello-world-c-output-validation",
"extra_ld_vars": "$<<CK_EXTRA_LIB_M>>$",
"main_language": "c",
"print_files_after_run": [
"stderr.log",
"stdout.log"
],
"process_in_tmp": "yes",
"program": "yes",
"run_cmds": {
"default": {
"ignore_return_code": "no",
"run_time": {
"output_invariant_of_repeat": "yes",
"post_process_via_ck": {
"script_name": "process"
},
"run_cmd_main": "$#BIN_FILE#$ \"$#src_path#$\"",
"run_cmd_out1": "stdout.log",
"run_cmd_out2": "stderr.log",
"run_correctness_output_files": [
"tmp-ck-output.json"
],
"run_output_files": [
"tmp-ck-output.json",
"stdout.log",
"stderr.log"
]
}
}
},
"run_vars": {
"CK_ABS_DIFF_THRESHOLD": 0.1,
"CK_VAR1": 123,
"CK_VAR2": 666
},
"source_files": [
"hello-world.c"
],
"tags": [
"template",
"program",
"lang-c"
],
"target_file": "a",
"template": "yes"
}
36 changes: 36 additions & 0 deletions program/template-hello-world-c-output-validation/hello-world.c
@@ -0,0 +1,36 @@
/*
CK program template
See CK LICENSE.txt for licensing details
See CK COPYRIGHT.txt for copyright details
Developer: Grigori Fursin, 2018, Grigori.Fursin@cTuning.org, http://fursin.net
*/

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[])
{
char* env;
FILE* f;

printf("Hello world!\n\n");

env=getenv("CK_VAR1");
if (env!=NULL) {
printf("CK_VAR1=%s\n",env);

f=fopen("tmp-ck-output.json","w");
fprintf(f, "[%s]\n",env);
fclose(f);
}

env=getenv("CK_VAR2");
if (env!=NULL) {
printf("CK_VAR2=%s\n",env);
}

return 0;
}
43 changes: 43 additions & 0 deletions program/template-hello-world-c-output-validation/process.py
@@ -0,0 +1,43 @@
#
# Postprocessing CK template demo
#
# See CK LICENSE.txt for licensing details
# See CK COPYRIGHT.txt for copyright details
#
# Developer: Grigori Fursin, 2018, Grigori.Fursin@cTuning.org, http://fursin.net
#

import json
import os
import re
import sys

def ck_postprocess(i):

ck=i['ck_kernel']
rt=i['run_time']
deps=i['deps']

d={}

env=i.get('env',{})

return {'return':0}

# Check output with a reference one (can check numerical stability)

def ck_check_output(i):
ck=i['ck_kernel']

env=i.get('env',{})

r=ck.access({'action':'check_numerical',
'module_uoa':'program.output',
'file1':i['file1'],
'file2':i['file2'],
'abs_threshold':env.get('CK_ABS_DIFF_THRESHOLD','')})
return r

# Do not add anything here!

# Do not add anything here!

0 comments on commit fcf1b27

Please sign in to comment.