使用GMP的3x3矩阵向量乘法

时间:2018-12-26 14:42:48

标签: c++ performance gmp bignum

我有一个大(最多2048位)有符号整数(f.a,f.b,f.c)的矢量和一个有符号int64_t(aa,ab,ac,ac,ba,bb,bc,ca,cb,cc)的3x3矩阵。我想乘以上述矩阵来更新(f.a,f.b,f.c)。这在我的代码中多次发生,我进行了分析,发现上述步骤占用了我运行时的很大一部分。

当前我的代码如下

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.7.RELEASE)

2018-12-26 20:05:29.201  INFO 11939 --- [  restartedMain] com.siqes.TemplateprocessorApplication   : Starting TemplateprocessorApplication on dev-76 with PID 11939 (/root/IdeaProjects/templateprocessor/target/classes started by root in /root/IdeaProjects/templateprocessor)
2018-12-26 20:05:29.203  INFO 11939 --- [  restartedMain] com.siqes.TemplateprocessorApplication   : No active profile set, falling back to default profiles: default
2018-12-26 20:05:29.266  INFO 11939 --- [  restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@57b72439: startup date [Wed Dec 26 20:05:29 IST 2018]; root of context hierarchy
2018-12-26 20:05:31.222  WARN 11939 --- [  restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.IllegalStateException: To use SSL, the connector's protocol handler must be an AbstractHttp11JsseProtocol subclass
2018-12-26 20:05:31.235  INFO 11939 --- [  restartedMain] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-26 20:05:31.244 ERROR 11939 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is java.lang.IllegalStateException: To use SSL, the connector's protocol handler must be an AbstractHttp11JsseProtocol subclass
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:157) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-5.0.11.RELEASE.jar:5.0.11.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1242) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1230) [spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at com.siqes.TemplateprocessorApplication.main(TemplateprocessorApplication.java:10) [classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_191]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_191]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_191]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.7.RELEASE.jar:2.0.7.RELEASE]
Caused by: java.lang.IllegalStateException: To use SSL, the connector's protocol handler must be an AbstractHttp11JsseProtocol subclass
    at org.springframework.util.Assert.state(Assert.java:73) ~[spring-core-5.0.11.RELEASE.jar:5.0.11.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.SslConnectorCustomizer.customize(SslConnectorCustomizer.java:55) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeSsl(TomcatServletWebServerFactory.java:317) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.customizeConnector(TomcatServletWebServerFactory.java:300) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:166) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154) ~[spring-boot-2.0.7.RELEASE.jar:2.0.7.RELEASE]
    ... 13 common frames omitted


Process finished with exit code 0

我尝试在单独的线程中进行所有单独的乘法和加法,然后将它们加入(使用std :: thread),但这无可避免地降低了性能。我认为最好使用gmp的addmul_ui和submul_ui functions。但是,尽管我不确定为什么,但是总体上它们的速度变慢了。甚至百分之几的改善都会有所帮助。目标硬件是:

戴尔Inspiron 3670 64位 i5 -8400 @ 2.8 GHz 8GB内存 GPU:Geforce GTX 1060 3GB

0 个答案:

没有答案