Changeset 9ee2756 in sasmodels for sasmodels/generate.py
- Timestamp:
- Oct 19, 2017 12:31:30 PM (7 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 2c108a3
- Parents:
- 94f4543
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/generate.py
r8698a0d r9ee2756 167 167 import string 168 168 from zlib import crc32 169 from inspect import currentframe, getframeinfo 169 170 170 171 import numpy as np # type: ignore … … 685 686 # Load templates and user code 686 687 kernel_header = load_template('kernel_header.c') 687 dll_code = load_template('kernel_iq.c') 688 ocl_code = load_template('kernel_iq.cl') 689 #ocl_code = load_template('kernel_iq_local.cl') 688 kernel_code = load_template('kernel_iq.c') 690 689 user_code = [(f, open(f).read()) for f in model_sources(model_info)] 690 691 # What kind of 2D model do we need? 692 xy_mode = ('qa' if not _have_Iqxy(user_code) and not isinstance(model_info.Iqxy, str) 693 else 'qac' if not partable.is_asymmetric 694 else 'qabc') 691 695 692 696 # Build initial sources … … 713 717 714 718 # Define the parameter table 715 # TODO: plug in current line number 716 source.append('#line 716 "sasmodels/generate.py"') 719 lineno = getframeinfo(currentframe()).lineno + 2 720 source.append('#line %d "sasmodels/generate.py"'%lineno) 721 #source.append('introduce breakage in generate to test lineno reporting') 717 722 source.append("#define PARAMETER_TABLE \\") 718 723 source.append("\\\n".join(p.as_definition() … … 733 738 pars = ",".join(["_q"] + model_refs) 734 739 call_iq = "#define CALL_IQ(_q, _v) Iq(%s)" % pars 735 if _have_Iqxy(user_code) or isinstance(model_info.Iqxy, str): 736 if partable.is_asymmetric: 737 pars = ",".join(["_qa", "_qb", "_qc"] + model_refs) 738 call_iqxy = "#define CALL_IQ_ABC(_qa,_qb,_qc,_v) Iqxy(%s)" % pars 739 clear_iqxy = "#undef CALL_IQ_ABC" 740 else: 741 pars = ",".join(["_qa", "_qc"] + model_refs) 742 call_iqxy = "#define CALL_IQ_AC(_qa,_qc,_v) Iqxy(%s)" % pars 743 clear_iqxy = "#undef CALL_IQ_AC" 744 else: 740 if xy_mode == 'qabc': 741 pars = ",".join(["_qa", "_qb", "_qc"] + model_refs) 742 call_iqxy = "#define CALL_IQ_ABC(_qa,_qb,_qc,_v) Iqxy(%s)" % pars 743 clear_iqxy = "#undef CALL_IQ_ABC" 744 elif xy_mode == 'qac': 745 pars = ",".join(["_qa", "_qc"] + model_refs) 746 call_iqxy = "#define CALL_IQ_AC(_qa,_qc,_v) Iqxy(%s)" % pars 747 clear_iqxy = "#undef CALL_IQ_AC" 748 else: # xy_mode == 'qa' 745 749 pars = ",".join(["_qa"] + model_refs) 746 750 call_iqxy = "#define CALL_IQ_A(_qa,_v) Iq(%s)" % pars … … 761 765 # TODO: allow mixed python/opencl kernels? 762 766 763 ocl = kernels( ocl_code, call_iq, call_iqxy, clear_iqxy, model_info.name)764 dll = kernels( dll_code, call_iq, call_iqxy, clear_iqxy, model_info.name)767 ocl = kernels(kernel_code, call_iq, call_iqxy, clear_iqxy, model_info.name) 768 dll = kernels(kernel_code, call_iq, call_iqxy, clear_iqxy, model_info.name) 765 769 result = { 766 770 'dll': '\n'.join(source+dll[0]+dll[1]+dll[2]),
Note: See TracChangeset
for help on using the changeset viewer.