|
1 | 1 | import os |
2 | 2 | import subprocess |
3 | | -import ctypes |
4 | 3 | import tempfile |
5 | 4 |
|
6 | | -from math import ceil |
7 | 5 | from collections import OrderedDict |
8 | 6 | from io import StringIO |
9 | | -from operator import attrgetter |
10 | 7 |
|
11 | | -from cached_property import cached_property |
12 | 8 |
|
13 | 9 | from devito import Operator |
14 | | -from devito.arch import compiler_registry, platform_registry |
15 | | -from devito.data import default_allocator |
16 | 10 | from devito.exceptions import InvalidOperator |
17 | | -from devito.ir.clusters import ClusterGroup, clusterize |
18 | | -from devito.ir.equations import LoweredEq, lower_exprs |
19 | | -from devito.ir.iet import (Callable, CInterface, EntryFunction, FindSymbols, MetaCall, |
20 | | - derive_parameters, iet_build) |
| 11 | + |
| 12 | +from devito.ir.iet import Callable, MetaCall |
21 | 13 | from devito.ir.ietxdsl import (finalize_module_with_globals) |
22 | | -from devito.ir.stree import stree_build |
23 | | -from devito.ir.support import AccessMode, SymbolRegistry |
| 14 | +from devito.ir.support import SymbolRegistry |
24 | 15 | from devito.ir.ietxdsl.cluster_to_ssa import (ExtractDevitoStencilConversion, |
25 | 16 | convert_devito_stencil_to_xdsl_stencil) |
26 | | -from devito.logger import debug, info, perf, warning, is_log_enabled_for |
| 17 | +from devito.logger import debug, info, perf |
27 | 18 | from devito.operator.operator import IRs |
28 | | -from devito.operator.profiling import AdvancedProfilerVerbose, create_profile |
29 | | -from devito.operator.registry import operator_selector |
30 | | -from devito.parameters import configuration |
31 | | -from devito.passes import (Graph, lower_index_derivatives, generate_implicit, |
32 | | - generate_macros, minimize_symbols, unevaluate) |
| 19 | +from devito.operator.profiling import create_profile |
33 | 20 | from devito.passes.iet import CTarget |
34 | | -from devito.symbolics import estimate_cost |
35 | | -from devito.tools import (DAG, ReducerMap, as_tuple, flatten, |
36 | | - filter_sorted, frozendict, is_integer, split, timed_pass, |
37 | | - contains_val) |
38 | | -from devito.types import Evaluable, TimeFunction, Grid |
| 21 | +from devito.tools import as_tuple, flatten, filter_sorted |
| 22 | +from devito.types import Evaluable, TimeFunction |
39 | 23 | from devito.types.mlir_types import ptr_of, f32 |
40 | 24 | from devito.mpi import MPI |
41 | 25 |
|
|
48 | 32 | __all__ = ['XDSLOperator'] |
49 | 33 |
|
50 | 34 |
|
51 | | -# small interop shim script for stuff that we don't want to implement in mlir-ir |
52 | | -_INTEROP_C = """ |
53 | | -#include <time.h> |
54 | | -
|
55 | | -double timer_start() { |
56 | | - // return a number representing the current point in time |
57 | | - // it might be offset by a fixed ammount |
58 | | - struct timespec t; |
59 | | - clock_gettime(CLOCK_MONOTONIC, &t); |
60 | | - return (t.tv_sec) + (t.tv_nsec * 1e-9); |
61 | | -} |
62 | | -
|
63 | | -double timer_end(double start) { |
64 | | - // return time elaspes since start in seconds |
65 | | - return (timer_start() - start); |
66 | | -} |
67 | | -""" |
68 | | - |
69 | | - |
70 | 35 | class XDSLOperator(Operator): |
71 | 36 |
|
72 | 37 | _Target = CTarget |
@@ -357,7 +322,6 @@ def _lower(cls, expressions, **kwargs): |
357 | 322 |
|
358 | 323 | return IRs(expressions, clusters, stree, uiet, iet), byproduct, module |
359 | 324 |
|
360 | | - |
361 | 325 | @property |
362 | 326 | def cfunction(self): |
363 | 327 | """The JIT-compiled C function as a ctypes.FuncPtr object.""" |
@@ -406,3 +370,22 @@ def get_arg_names_from_module(op): |
406 | 370 | return [ |
407 | 371 | str_attr.data for str_attr in op.body.block.ops.first.attributes['param_names'].data # noqa |
408 | 372 | ] |
| 373 | + |
| 374 | + |
| 375 | +# small interop shim script for stuff that we don't want to implement in mlir-ir |
| 376 | +_INTEROP_C = """ |
| 377 | +#include <time.h> |
| 378 | +
|
| 379 | +double timer_start() { |
| 380 | + // return a number representing the current point in time |
| 381 | + // it might be offset by a fixed ammount |
| 382 | + struct timespec t; |
| 383 | + clock_gettime(CLOCK_MONOTONIC, &t); |
| 384 | + return (t.tv_sec) + (t.tv_nsec * 1e-9); |
| 385 | +} |
| 386 | +
|
| 387 | +double timer_end(double start) { |
| 388 | + // return time elaspes since start in seconds |
| 389 | + return (timer_start() - start); |
| 390 | +} |
| 391 | +""" |
0 commit comments